[R] Lattice wireframe or cloud plot with different colours by a group

David Winsemius dwinsemius at comcast.net
Sat Apr 2 01:46:59 CEST 2011


On Apr 1, 2011, at 6:21 PM, Pam Allen wrote:

> I have a question about wireframe 3-D plots and how to apply  
> colors.  I have
> a large dataset of river flow (m^3/s) over time, and I have coded  
> these
> flows based on their height.  I would like to produce a wireframe  
> plot that
> colors the graph based on the flow code, i.e. I would like high  
> flows to be
> red, medium to be green and low flows to be blue.  Here is some  
> sample data
> with the basic wireframe plot:
>
> flow.dat=cbind.data.frame(flow=sin(2*pi/53*c(1:3000)) 
> +1,day=as.numeric(format(as.Date(c(1:3000)),
> format="%j")), year=as.numeric(format(as.Date(c(1:3000)),
> format="%Y")),grp=c(rep(c("1.high","2.med","3.low"),1000)))

It does not look to me that high flows are properly grouped with `grp`.

>
> wireframe(flow~day*year, data=flow.dat, shade=T)

  wireframe(flow~day*year, data=flow.dat,  drape=TRUE,  
col.regions=c("#FF3030","#551A8B","#43CD80"),
           at=c(0,.6,1.3,1.8))

Because of the coding at the corner and the long thin polygons you  
have specified with your day*year splits you get slanting colors.

>
> Is there any way to specify what colours are passed to the plot?  I.e.
> wireframe(flow~day*year, data=flow.dat, shade=T, groups=grp,
> col.group=c("#FF3030","#551A8B","#43CD80"))
>
> I would also be happy if I could do this with a cloud plot, but I  
> can't get
> the colors to plot correctly.
> cloud(flow~day*year, data=flow.dat, shade=T, groups=grp,
> col.group=c("#FF3030","#43CD80","#1E90FF"), pch=20)
>
> Any help is much appreciated!  Thank you.
>
> -Pam Allen
>
> allen_pam at hotmail.com
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Lattice-wireframe-or-cloud-plot-with-different-colours-by-a-group-tp3421296p3421296.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list