使用doubleYScale绘图更改y轴文本大小

use*_*355 5 r lattice

我做了一个doubleYScale情节:

library(lattice)
library(latticeExtra)

# Some data
foo <- list(x = 1:100, y = cumsum(rnorm(100)))

obj1 <- xyplot(y~ x, data=foo,xlab=list(cex=1.2), 
               main="TOtalProduktion VS SummaSkulder/TotaltKapital i procent",
               type = c("l","g"),col="black",
               lty=1,key = simpleKey(col=c('black'),
               text=c("Produktion"),cex=1.2,points=FALSE, lines=TRUE),
               scales=list(x=list(rot=90,tick.number=25,
               cex=1,axs="r")))

obj2 <- xyplot(y^2 ~ x,data= foo ,type = "o",col="black",
               lty=9,key = simpleKey(col=c('black'),
               text=c("Summa.skulder"),cex=1.2,lines=FALSE,points= TRUE))

doubleYScale(obj1, obj2, add.ylab2 = TRUE)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

problem是我无法改变y轴标签的文本大小(yy^2文本,我想让它更大).如果我只绘制obj1obj2单独绘制它是没有问题,但它不适用于doubleYScale......

另一方面,我可以使用以下方法更改y轴上的数字大小:

trellis.par.set(axis.text=list(cex=1))
Run Code Online (Sandbox Code Playgroud)

有什么建议?我找不到办法:(

spa*_*row 5

这是另一个直接使用lattice和的解决方案latticeExtra:您可以在其中单独设置所有轴标签的大小:

library(lattice)
library(latticeExtra)
foo <- list(x = 1:100, y = cumsum(rnorm(100)))

obj1 <- xyplot(y~ x, data=foo,
               xlab=list("Thing", fontsize = 22),
               ylab = list("Something", fontsize = 32),
               ylab.right = list("Anything", fontsize = 16),
               par.settings = simpleTheme(col = 1),
               type = c("l","g"),
               lty=1,
               scales=list(x=list(rot=90,tick.number=25,
                                  cex=1,axs="r")))

obj2 <- xyplot(y^2 ~ x,data= foo ,type = "o",col="black",
               lty=9)

doubleYScale(obj1, obj2)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


ags*_*udy 4

    library(grid)
    ##  the text size of the 2 y-axic labels
    grid.edit(gPath='GRID.text',grep=T,global=T,gp =gpar(cex=3))
Run Code Online (Sandbox Code Playgroud)

如果你想设置不同的轴尺寸

    grobs <- sapply(grid.get(gPath='GRID.text',grep=T,global=T),'[')['name',]
    grid.edit(gPath=grobs[[1]],gp =gpar(cex=2))
    grid.edit(gPath=grobs[[2]],gp =gpar(cex=1.5))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述