[R] fill circles

hadley wickham h.wickham at gmail.com
Sun Aug 26 18:35:26 CEST 2007


Hi Christian,

You could use the ggplot2 package (http://had.co.nz/ggplot2) which
takes care of many of these details for you:

qplot(Height, Volume, data=trees, size = Girth)
qplot(Height, Volume, data=trees, size = Girth, colour=Height)

You can find more details on the website about how to customise the
scales for your needs, but the defaults should be pretty good.

Hadley

On 8/25/07, Cristian cristian <taccioli at gmail.com> wrote:
> Hi all,
> I'm an R newbie,
> I did this script to create a scatterplot using the "tree" matrix from
> "datasets" package:
>
> library('datasets')
> with(trees,
> {
> plot(Height, Volume, pch=3, xlab="Height", ylab="Volume")
> symbols(Height, Volume, circles=Girth/12, fg="grey", inches=FALSE,
> add=FALSE)
> }
> )
>
> I'd like to use the column Named "Height" to fill the circles with colors
> (ex.: the small numbers in green then yellow and the high numbers in red).
> I'd like to have a legend for the size and the colors too.
> I did it manually using a script like that:
> color[(x>=0.001)&(x<0.002)]<-"#41FF41"
> color[(x>=0.002)&(x<0.003)]<-"#2BFF2B"
> color[(x>=0.003)&(x<0.004)]<-"#09FF09"
> color[(x>=0.004)&(x<0.005)]<-"#00FE00"
> color[(x>=0.005)&(x<0.006)]<-"#00F700"
> color[(x>=0.006)&(x<0.007)]<-"#00E400"
> color[(x>=0.007)&(x<0.008)]<-"#00D600"
> color[(x>=0.008)&(x<0.009)]<-"#00C300" and so on but I don't like to do it
> manually... do know a solution...
> Thank you very much
> chris
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
http://had.co.nz/



More information about the R-help mailing list