[R] more outrageous plotting

Jim Lemon jim at bitwrit.com.au
Fri Nov 23 10:13:12 CET 2007


Juan Pablo Fededa wrote:
> Dear Contributors:
> 
> I have the next matrix:
> 
> "X" "Y" "Z"
> 
> 1     2      526
> 2     5      723
> 3    10     110
> 4     7      1110
> 5     9       34
> 6     8      778
> 7     1       614
> 8     4       876
> 9     6       249
> 10   3       14
> 
> I want to order the matrix from bigest Z (1110) to lower Z (14).
> Then I want to asign a color scale vector from blue ( bigest Z) to
> orange (lower Z), and then I want to make a plot with the X vs.Y
> coordinates of the matrix, with the number correspondent to Z in every
> point, each number coloured with the assigned colour scale colour.
> Is this doable?????

Sure, but I don't think you need to order the rows to do it:

library(plotrix)
jpf<-read.csv("jpf.csv")
plot(jpf$X,jpf$Y,main="Test of color/text plot",
  type="n")
text(jpf$X,jpf$Y,labels=jpf$Z,
  col=color.scale(jpf$Z,extremes=c("orange","blue")))

Note that the "extremes" argument will only work properly in the latest 
version of plotrix.

Jim



More information about the R-help mailing list