在 R 中使用来自 latticeExtra 的 doubleYScale 时如何更改 Y 轴刻度的字体大小
How to change font size of Y axis scales when using doubleYScale from latticeExtra in R
我想在使用 doubleYScale 时更改 Y 轴刻度的字体大小(不是标签,而是刻度旁边的数字)。我已经设法更改了 X 轴的字体大小,包括 X 轴和 Y 轴标签,但是我在为 Y 轴字体大小而苦苦挣扎。
foo <- list(x = 1:100, y = cumsum(rnorm(100)))
obj1 <- xyplot(y ~ x, foo, type = "l", scales = list(y = list(cex=2)))
obj2 <- xyplot(y ^ 2 ~ x, foo, type = "l", scales = list(y = list(cex = 2)))
doubleYScale(obj1, obj2, add.axis = TRUE)
这里cex对y轴刻度的字体大小没有影响。我应该怎么做?
在您的情况下,也许最简单的方法是:
library(lattice)
library(latticeExtra)
trellis.par.set(axis.text=list(cex=2))
doubleYScale(obj1, obj2, add.axis = TRUE)
如果您不想更改默认设置,请尝试以下操作:
update(doubleYScale(obj1, obj2, add.axis = TRUE),
par.settings =list(axis.text=list(cex=2)))
我的设置:
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] latticeExtra_0.6-28 RColorBrewer_1.1-2 lattice_0.20-38
loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1 grid_3.6.1
我想在使用 doubleYScale 时更改 Y 轴刻度的字体大小(不是标签,而是刻度旁边的数字)。我已经设法更改了 X 轴的字体大小,包括 X 轴和 Y 轴标签,但是我在为 Y 轴字体大小而苦苦挣扎。
foo <- list(x = 1:100, y = cumsum(rnorm(100)))
obj1 <- xyplot(y ~ x, foo, type = "l", scales = list(y = list(cex=2)))
obj2 <- xyplot(y ^ 2 ~ x, foo, type = "l", scales = list(y = list(cex = 2)))
doubleYScale(obj1, obj2, add.axis = TRUE)
这里cex对y轴刻度的字体大小没有影响。我应该怎么做?
在您的情况下,也许最简单的方法是:
library(lattice)
library(latticeExtra)
trellis.par.set(axis.text=list(cex=2))
doubleYScale(obj1, obj2, add.axis = TRUE)
如果您不想更改默认设置,请尝试以下操作:
update(doubleYScale(obj1, obj2, add.axis = TRUE),
par.settings =list(axis.text=list(cex=2)))
我的设置:
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] latticeExtra_0.6-28 RColorBrewer_1.1-2 lattice_0.20-38
loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1 grid_3.6.1