Question

I'm trying to use a trellis theme to set all my graphing parameters to keep my plotting statements short. I can't seem to find the correct trellis parameter access tick mark length (or any scale parameters for that matter).

library(lattice)

x = runif(100)
my.theme = trellis.par.get()
my.theme$axis.line = list(tck=c(4))     # this does not work
dp <- densityplot(~x)

# this works, but I want to do it using a theme
# dp <-densityplot(~x, scales=list(y=list(tck=c(4)))) 

png("dp.png", width=400, height=200)
trellis.par.set(my.theme)
plot(dp); dev.off()
Was it helpful?

Solution

Tick lengths for each of the plot's axes are controlled by (elements of) axis.components in lattice's graphical parameter list.

Run str(trellis.par.get("axis.components")) to see what you are aiming for, and then do something like the following:

mytheme <- list(axis.components = list(left = list(tck=4), right = list(tck=4)))
trellis.par.set(mytheme)
densityplot(~x)

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top