使用latticeExtra:::c.trellis合并绘图时,右侧的刻度线和文本/数字标签丢失,我想要恢复它们:
library(latticeExtra)
set.seed(1)
foo <- data.frame(x = 1:100,
y = 1:100 + rnorm(100))
foo$resid <- with(foo, x-y)
## Plot 1 -----
(p1 <- xyplot(y~x, foo))
## Plot 2 -----
(p2 <-
xyplot(resid~x, foo,
scales = list(rot = 0, tck = c(1,1), alternating = 3),
between = list(y = 1), ylab.right = "ylab.right",
# par.settings = list(axis.components =
# list(right = list(pad1 = 2, pad2 = 2)))
# Note: this padding attempt does not restore the missing ticks,
# pad arguments get ignored when using c.trellis below
))
# tick marks appear on all four sides (as desired)
## Combine -----
(p12 <- latticeExtra:::c.trellis(p2, p1,layout = c(1,2)))
# right tick marks are missing有没有办法手动恢复右侧的刻度和/或标签,比如通过修改组合的trellis对象?
发布于 2019-08-26 01:30:51
从帮助文件?c.trellis
描述
将多个网格对象的面板合并为一个。
后来,
请注意,组合来自不同类型绘图的面板并不真正适合网格模型。绘图的某些功能可能无法按预期工作。特别是,可能需要做一些工作来显示或隐藏选定面板上的比例。下面给出了一个示例。
在我看来,你并不是真的想把面板组合成一个对象。您甚至可以使用between来进行一些分隔。相反,您正在尝试合并两个图。
您可以使用print,
print(p1,split=c(1,1,1,2),more=TRUE)
print(p2,split=c(1,2,1,2),more=FALSE)参见?print.trellis。
https://stackoverflow.com/questions/57578983
复制相似问题