Re: [R] Lattice Cloud()-Plot with the same color for different groups

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue, 27 May 2008 11:54:55 -0700

On 5/27/08, Charilaos Skiadas <cskiadas_at_gmail.com> wrote:
>
> On May 27, 2008, at 3:10 AM, Hofert Marius wrote:
>
>
> > Hi,
> >
> > Consider the following cloud()-plot consisting of two lines:
> >
> > library(lattice)
> >
> mydata=data.frame(x=rep(1:4,2),y=rep(1:2,each=4),z=c(1,2,3,4,4,3,2,1))
> > cloud(z~x*y,data=mydata,groups=y,type=rep("l",2))
> >
> > Now, I would like to change the color of the lines (still works fine):
> >
> >
> cloud(z~x*y,data=mydata,groups=y,type=rep("l",2),col=c(1,2))
> >
> > But when I change the color to be the same for each group, i.e. for both
> lines, then the groups are "combined" by a line:
> >
> >
> cloud(z~x*y,data=mydata,groups=y,type=rep("l",2),col=c(2,2))
> >
> > How do I remove this group-combining line so that the cloud()-plot looks
> like in the first plot above, but with the same colors for each line?
> Assigning the color in the data.frame mydata also did not help.
> >
>
> Interesting behaviour, I would consider it a bug.

It's definitely a bug, related to an attempt by panel.3dscatter to draw the lines in order of "depth". A temporary workaround (that will work only if a color is repeated a limited number of times) is to specify the colors in representations that are different (as strings); e.g.,

cloud(z~x*y,data=mydata,groups=y,type="l",col=c("#ff0000", "#FF0000"))

-Deepayan



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 Tue 27 May 2008 - 20:05:03 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 Tue 27 May 2008 - 20:32:14 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