On 03/01/2013 10:54 AM, Benoit Gendreau-Berthiaume wrote:
Hello I am  trying to plot a 20 x 20 grid of points with the colors of each
point refering to percent cover of that specific point

So basically the point are all the same size and their position on the
graph is base on their coordinates (x,y). I want the color (a grey scale
from white=0 to black =100) to represent the values of each of these point
(cover)

Here is what my data looks like
         x     y           cover
A1   0   95             3.0
A2   5   95             0.5
A3  10  95            10.0
...etc
Up to now I have tried
plot(Q.xy[,1],Q.xy[,2],pch=16, cex=2.6, col=heat.colors(8)[x[,3]])
I put 8 after heat colors because their are 8 different values in my cover
column

My problem is that I only get one color out this line of code. Regardless
of which number I put after heat.colors I always have the same quadrats
colored with only one color.

Any idea of how to get 8 colors in my graph?
and how to make sure they are associated with the good cover values?

Hi Benoit,
This can be done with a number of R functions. I will shamelessly demonstrate one that I wrote myself:

Q<-data.frame(x=sample(0:100,20),y=sample(0:100,20),
 cover=runif(20,0,100))
library(plotrix)
Qcolors<-color.scale(Q$cover,extremes=c("white","black"),
 xrange=c(0,100))
plot(Q$x,Q$y,pch=21,col="black",bg=Qcolors,cex=2)

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to