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

From: Pam Allen <allen_pam_at_hotmail.com>
Date: Fri, 01 Apr 2011 17:21:28 -0500 (CDT)

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)))

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

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



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. Received on Fri 01 Apr 2011 - 22:51:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 02 Apr 2011 - 00:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive