[R] Trellis settings get lost when printing to pdf

Sundar Dorai-Raj sdorairaj at gmail.com
Fri Nov 13 19:09:21 CET 2009


Did you make the changes before or after starting the device:

library(lattice)
## before doesn't change the settings on the device:
trellis.par.set(plot.symbol = list(col = "red"))
trellis.device(pdf, file = "tmp.pdf")
xyplot(1 ~ 1)
dev.off()

## after does
trellis.device(pdf, file = "tmp.pdf")
trellis.par.set(plot.symbol = list(col = "red"))
xyplot(1 ~ 1)
dev.off()

I never do things like this, though. I would suggest creating a theme
instead and supplying it to xyplot (or whatever plot you're using)
using par.settings:

my.theme <- list(plot.symbol = list(col = "red"))
trellis.device(pdf, file = "tmp.pdf")
xyplot(1 ~ 1, par.settings = my.theme)
dev.off()

HTH,

--sundar


2009/11/13 Joel Fürstenberg-Hägg <joel_furstenberg_hagg at hotmail.com>:
>
> Hi all,
>
>
>
> I've got some problems when changing the trellis settings for the lattice plots. The plots look exactly as I want them to when calling show.settings() as well as when plotting them in the graphical window. But when printing to a pdf file, none of the settings are used!? Does anyone know what might have happened? Because the when changing the trellis settings, these should remain in the new state until you close R right..?
>
>
>
> # Change settings for the boxplot appearance
> new.dot=trellis.par.get("box.dot")
> new.rectangle=trellis.par.get("box.rectangle")
> new.umbrella=trellis.par.get("box.umbrella")
> new.symbol=trellis.par.get("plot.symbol")
> new.strip.background=trellis.par.get("strip.background")
> new.strip.shingle=trellis.par.get("strip.shingle")
> new.dot$pch="|"
> new.dot$col="black"
> new.rectangle$col="black"
> new.rectangle$fill="grey65"
> new.umbrella$col="black"
> new.umbrella$lty=1 # Continous line, not dotted
> new.symbol$col="black"
> new.strip.background$col="grey87" # Background colour in the upper label
> new.strip.shingle$col="black" # Border colour around the upper label
> trellis.par.set(box.dot=new.dot, box.rectangle=new.rectangle, box.umbrella=new.umbrella, plot.symbol=new.symbol, strip.background=new.strip.background, strip.shingle=new.strip.shingle)
>
>
>
> Best regards,
>
>
>
> Joel
>
> _________________________________________________________________
> Nya Windows 7 - Hitta en dator som passar dig! Mer information.
> http://windows.microsoft.com/shop
>        [[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