문제

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()
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top