[R] lattice - change background strip color in one panel
P Ehlers
ehlers at ucalgary.ca
Fri May 27 14:14:08 CEST 2011
On 2011-05-27 0:48, Coen van Hasselt wrote:
> Hello,
>
> I would like to change the background color in only -one- of the strips in a
> multipanel lattice xyplot, from the default yellow-brown color.
> Until now, I only managed to change the background strip color in all of the
> strips using the par.settings, but I do not get it to work for only 1 strip.
>
> Below is the current code I am using.
> The resulting plot is here:
> http://dl.dropbox.com/u/9788680/01_DoseIntensity_MonitoringInterval_BW.pdf
> (i.e. I'd like to color the "3 months" strip in red)
>
> xyplot(value~ant|paste(intv, "Months"), groups=perc, data=di,
> type="b", layout=c(4,1),xlab="Prior anthracyclines",
> lty=c(1,2),lwd=2,col="black",main="Dose intensity ~ Monitorings Interval",
> ylab="Dose intensity",
> scales=list(x=list(at=c(0,0.5,1)),y=list(at=seq(0,1,.1))),
> par.settings = list(superpose.line=list(lwd=2,lty=1:2, col="black")),
>
> auto.key = list(space = "right", points = FALSE, ncol=3,nrow=1, lines
> = TRUE, title="Percentiles", cex=.7, cex.title=.7, siz=6))
>
> I would greatly appreciate it if someone could guide me in the right
> direction!
See if this helps:
xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris,
par.settings=list(strip.background=list(col=c('green','red','blue'))),
strip = function(..., bg) {
strip.default(...,
bg = trellis.par.get("strip.background")$col[which.packet()])
})
See ?strip.default.
Peter Ehlers
>
> Thanks
>
> Coen
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list