Я строю два xyplots с двойной шкалой и некоторые изменения в том, как отображаются оси. Я пытаюсь изменить размеры шрифта всего текста, но «размер шрифта» не влияет ни на метки оси, ни на метки. Только «cex» работает для меток тиков, но не для меток осей, и при этом он перекрывает метки осей.
library(lattice)
library(latticeExtra)
library(grid)
## Sample data
x <- seq(1:10)
y <- x^2
y2 <- x*2
## Prepare list of scales setting that suppresses ticks on top axis
myScales <- list(x = list(tck = c(1,0)))
## Prepare parameter settings, including setting the color used in
## plotting axis line to "transparent"
myTheme <- simpleTheme(col = c("black", "red"),
lty = c(1,1))
myTheme <- c(myTheme, list(axis.line = list(col = "transparent")))
myTheme <-c(myTheme, list(par.main.text = list(font = 1, # make it bold
just = "left", x = grid::unit(5, "mm"), fontsize=16)), list(axis.text=list(fontsize=16)))
## Write a custom axis function that only plots axis lines on the
## left, right, and bottom sides
myAxisFun <- function(side, line.col, ...) {
if (side == "left") {
grid.lines(x = c(0, 0), y = c(0, 1),
default.units = "npc")
} else if (side == "right") {
grid.lines(x = c(1, 1), y = c(0, 1),
default.units = "npc")
} else if (side == "bottom") {
grid.lines(x = c(0, 1), y = c(0, 0),
default.units = "npc")
}
axis.default(side = side, line.col = "black", ...)
}
## Construct two component plots
plot1 <- xyplot(y ~ x, col="black", type = "l",
ylab = "Label1", xlab = "",
par.settings = myTheme,
scales = myScales,
axis = myAxisFun,
main="Title")
plot2 <- xyplot(y2 ~ x, col="red", type = "l",
ylab = "Label2", xlab = "",
par.settings = myTheme,
scales = myScales,
axis = myAxisFun)
## Meld the two plots
doubleYScale(plot1, plot2, add.ylab2 = TRUE)
При изменении «fontsize = 16» в axis.text вызывать «cex = 2» (для иллюстрации перекрытия)