deepayan / yagpack

Yet another graphics package for R

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

theme argument in yplot affects other plots

tverbeke opened this issue · comments

Specifying the theme argument in one single plot affects all subsequent plots. It may be desirable to allow for general themes and plot-specific themeing.

library(imp.lattice)

if (interactive()) x11() else pdf()
.yagpenv$backend <- graphics_primitives()

data(pressure)

x11()

.yagpenv$theme <- yagp.theme("default")
.yagpenv$theme$background
# $col
# [1] "#eeeeee"


.yagpenv$theme <- yagp.theme("trellis")
.yagpenv$theme$background
# $col
# [1] "#909090"


data(pressure)
p <- yplot(data = pressure,
    panel.vars = elist(x = temperature, y = pressure),
    panel = ypanel.xyplot(col="blue") + 
        ypanel.abline(h = 200, col = "orange", lwd = 2),
    pch = 19, xlab = "Temp (Celsius)", ylab = "Pressure (mm Hg)",
    theme = yagp.theme("default"), # permanently sets the theme
)
p

.yagpenv$theme$background
# $col
# [1] "#eeeeee"