Re: [R] Setting the colors of lines in a trellis plot...

From: Jamieson Cobleigh <cobleigh_at_gmail.com>
Date: Tue 11 Jul 2006 - 03:38:45 EST

The col command worked.

Thanks!

Jamie

On 7/10/06, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
> Use col= to specify colors, e.g.
>
> library(lattice)
> x <- 1:12
> xyplot(x ~ x, group = gl(3,4), col = 1:3, type = "l", auto.key = TRUE)
>
> If this is not sufficiently close to your problem
> 1. cut your example down to a *minimal* size and
> 2. provide it as *self contained* and
> 3. *reproducible* code.
>
> On 7/10/06, Jamieson Cobleigh <cobleigh@gmail.com> wrote:
> > With some help from those with expertise on this list, I managed to
> > produce a plot using trellis that looked like I wanted it to look.
> > Now, I need to take the same plot and make the lines on it color, but
> > I want to specify the color for the lines myself.
> >
> > I've managed to make the key use the colors I want. I've managed to
> > make the symbols of the actual plot use the colors I want. But I have
> > been unable to find the correct incantation to make the lines of the
> > actual plot use the colors I want. Here's the relevant section of
> > code:
> >
> > mycolors <- c("black", "darkgreen", "red")
> >
> > mylines <- Rows(superpose.line, 1:numlines);
> > mylines$col <- mycolors
> >
> > mysymbols <- Rows(superpose.symbol, 1:numlines);
> > mysymbols$pch <- c(15:18)[1:numlines]
> > mysymbols$col <- mycolors
> >
> > print(xyplot(
> > panel = panel.superpose,
> > log10(states) ~ size,
> > groups=category,
> > data=data,
> > type='b',
> > lwd = 2,
> > par.settings = list(superpose.symbol=mysymbols),
> > ylim=c(y_min, y_max),
> > scales = list(tck=c(1, 0), axs="r",
> >
> > x=list(tick.number=(xmax - xmin + 1), at=xmin:xmax,
> > labels=xmin:xmax, cex=1.75),
> >
> > y=list(axs="r", rot=c(90, 0), labels=y_labels,
> > at=y_at, cex=1.75
> > )
> > ),
> > key = list (
> > text = list(levels(data$category)),
> > lines = list(type="b",
> > lty=mylines$lty,
> > pch=mysymbols$pch,
> > cex=rep(1.25, numlines),
> > col=mylines$col),
> > x = .98,
> > y = .25,
> > corner=c(1,0)
> > ),
> > xlab = list(label="System Size", cex=2),
> > ylab = list(label="States", cex=2),
> > ))
> >
> >
> > Can anyone help me out with this?
> >
> > Thanks!
> >
> > Jamie
> >
> > ______________________________________________
> > R-help@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
> >
>



R-help@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 Received on Tue Jul 11 03:42:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 11 Jul 2006 - 04:16:57 EST.

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