[R] Lattice key title color

Greg Snow Greg.Snow at imail.org
Wed Oct 15 17:18:58 CEST 2008


Another way to look through the possible par settings that hopefully makes it a little less intimidating is:

> library(TeachingDemos)
> TkListView(trellis.par.get())

This requires the TeachingDemos package (obviously) and the tcltk package (most have it, but sometimes you need to run R a certain way for it to work).

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Dieter Menne
> Sent: Wednesday, October 15, 2008 8:18 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] Lattice key title color
>
> Meesters, Erik <Erik.Meesters <at> wur.nl> writes:
>
> > is there a way to define the color of the title for the legend in
> > lattice?
>
> Getting the right par to set in lattice can be intimidating. I keep the
> result
> of trellis.par.get() in a text file and search for the "closest match".
>
> Dieter
>
> library(lattice)
> show.settings() # does not help much here (wish this were more
> complete..)
> # capture the following output into a text file
> trellis.par.get()
> # end of trying around, let's work
>
> # you need to know that the title called "main"
> pars = trellis.par.get("par.main.text")
> pars$col="red"
> trellis.par.set("par.main.text",pars)
>
> xyplot(rnorm(100)~rnorm(100),main="Hello")
>
> # I normally use the following method to set many of my pars at once
>
> "DMlatticeOptions" <- function(superpose.polygon.col=NULL,
>                               superpose.line.col=NULL) {
>   require(lattice)
>   require(RColorBrewer)
>   ltheme = canonical.theme(color=TRUE)
>
>   if (!is.null(superpose.polygon.col))
>     ltheme$superpose.line$col =  superpose.line.col else
>     ltheme$superpose.line$col =
>       c('black',"red","blue","#e31111","darkgreen", "gray")
> #  ltheme$superpose.line$col = rev(brewer.pal(8,"Set1"))
>   ltheme$superpose.fill$col = ltheme$superpose.line$col
>   if (!is.null(superpose.polygon.col))
>     ltheme$superpose.polygon$col =  superpose.polygon.col
>   ltheme$strip.shingle$col = ltheme$superpose.polygon$col
>
>   ltheme$superpose.symbol$pch = c(16,17,18,1,2,3,4,8)
>   ltheme$superpose.symbol$col = ltheme$superpose.line$col
>   ltheme$superpose.symbol$cex = 0.4
>   ltheme$strip.background$col = c("gray90", "gray80")
>   ltheme$background$col = "transparent"
>   ltheme$par.main.text$cex = 0.9 # default is 1.2
>   ltheme$par.ylab.text$cex =0.8
>   ltheme$par.ylab.text$cex =0.8
>   ltheme$add.text$cex = 1
>   ltheme$axis.text$cex = 0.6
>   ltheme$box.rectangle$col = "black"
>   ltheme$box.umbrella$col = "black"
>   ltheme$dot.symbol$col = "black"
>
>   ltheme$plot.symbol$col = "black"
>   ltheme$plot.line$col = "black"
>   ltheme$plot.symbol$cex = 0.3
>   ltheme$plot.symbol$pch = c(16)
>
>   ltheme$plot.polygon$col = "#A6D96A"
>   ltheme$par.sub.text$cex=0.7
>   ltheme$par.sub.text$font=1
>
>   lattice.options(default.theme=ltheme)
> }
>
> ______________________________________________
> 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