[R] Ploting different values with different colors
PIKAL Petr
petr.pikal at precheza.cz
Fri Mar 1 08:32:23 CET 2013
Hi
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Benoit Gendreau-Berthiaume
> Sent: Friday, March 01, 2013 12:54 AM
> To: r-help at r-project.org
> Subject: [R] Ploting different values with different colors
>
> 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
Well, you did not provide much info to let us help you. What is e.g. x[,3]?
I can only guess, that it is the same as cover variable. If yes, you need to change it to ordered factor, if you want to use it for selection.
something like
sel.col<-ordered(x[,3])
plot(Q.xy[,1],Q.xy[,2],pch=16, cex=2.6, col=heat.colors(8)[as.numeric(sel.col)])
can do what you want if there is really only 8 unique values.
You could also consider some graphic devices which can use alpha transparency
??alpha
Regards
Petr
> 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?
>
> Thanks
> Benoit Gendreau-Berthiaume
> PhD Candidate
> Department of Renewable Resources
> University of Alberta
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list