,传入(i)图的参数; (ii) more ,设置为TRUE,仅传递给初始调用print,以及(iii) pos ,它给出了每个绘图在页面上的位置,指定为xy坐标对,用于绘图的左下角角和右上角 - 分别是一个带有四个数字的向量 .
更容易展示而不是告诉:
data(AirPassengers) # a dataset supplied with base R
AP = AirPassengers # re-bind to save some typing
# split the AP data set into two pieces
# so that we have unique data for each of the two plots
w1 = window(AP, start=c(1949, 1), end=c(1952, 1))
w2 = window(AP, start=c(1952, 1), end=c(1960, 12))
px1 = xyplot(w1)
px2 = xyplot(w2)
# arrange the two plots vertically
print(px1, position=c(0, .6, 1, 1), more=TRUE)
print(px2, position=c(0, 0, 1, .4))
3 回答
'lattice'包构建在网格包上,并在加载'lattice'时附加其命名空间 . 但是,为了使用
grid.layout
函数,您需要显式地load()
pkg :: grid . 另一个可能更容易的选择是pkg :: gridExtra中的grid.arrange
函数:莱迪思软件包经常(但不总是)忽略par命令,因此我在绘制w / Lattice时避免使用它 .
要在单个页面上放置多个点阵图:
create (但不要绘制)格子/格子 plot objects ,然后
为每个情节调用 print 一次
每次打印调用
更容易展示而不是告诉:
一旦你阅读
?print.trellis
,这很简单 . 特别感兴趣的是split
参数 . 乍一看似乎很复杂,但一旦你理解了它的意义,它就会非常简单 . 从文档:您可以在
example(print.trellis)
上看到几个实现,但这是我更喜欢的一个:上面的代码给出了这个数字:
如您所见,
split
有四个参数 . 最后两个参考框架的大小(类似于mfrow
的大小),而前两个参数将您的图形定位到nx
byny
框架 .