格子:一个窗口中的多个图?
我试图通过设置 par(mfrow=c(2,1))
使用 levelplot
在一个窗口中放置多个格子图,但它似乎忽略了这一点。
是否有一个特定的函数可以在lattice
中设置多个绘图?
I'm trying to put multiple lattice plots in one window using levelplot
by setting par(mfrow=c(2,1))
but it seems to be ignoring this.
Is there a particular function for setting multiple plots in lattice
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“lattice”包构建在 grid 包之上,并在加载“lattice”时附加其名称空间。但是,为了使用
grid.layout
函数,您需要显式load()
pkg::grid。另一种选择可能更简单,是 pkg::gridExtra 中的grid.arrange
函数:The 'lattice' package is built on the grid package and attaches its namespace when 'lattice' loaded. However, in order to use the
grid.layout
function, you need to explicitlyload()
pkg::grid. The other alternative, that is probably easier, is thegrid.arrange
function in pkg::gridExtra:Lattice 包经常(但并非总是)忽略 par 命令,因此我只是在使用 Lattice 进行绘图时避免使用它。
要在单个页面上放置多个晶格图:
创建(但不绘制)晶格/网格绘图对象,然后
为每个图调用 print 一次
对于每个 print 调用,传入 (i) 图 的参数; (二)
更多,设置为TRUE,并且仅在初始调用print时传入,并且(iii ) pos,给出页面上每个图的位置,指定为图左下角和右上角的 xy 坐标对
分别是角点,即具有四个数字的向量。
展示比讲述容易得多:
The Lattice Package often (but not always) ignores the par command, so i just avoid using it when plotting w/ Lattice.
To place multiple lattice plots on a single page:
create (but don't plot) the lattice/trellis plot objects, then
call print once for each plot
for each print call, pass in arguments for (i) the plot; (ii)
more, set to TRUE, and which is only passed in for the initial call to print, and (iii) pos, which gives the position of each plot on the page specified as x-y coordinate pairs for the plot's lower left-hand corner and upper right-hand
corner, respectively--ie, a vector with four numbers.
much easier to show than to tell:
一旦您阅读了
?print.trellis
,这一切就很简单了。特别令人感兴趣的是split
参数。乍一看似乎很复杂,但一旦你理解了它的含义,它就非常简单了。从文档中:您可以在
example(print.trellis)
上看到几个实现,但这是我更喜欢的一个:上面的代码为您提供了下图:
如您所见,
split
采用四个参数。 最后两个指的是框架的大小(类似于mfrow
所做的),而前两个参数将您的绘图定位到< code>nx 到ny
框架。This is simple to do once you read
?print.trellis
. Of particular interest is thesplit
parameter. It may seem complicated at first sight, but it's quite straightforward once you understand what it means. From the documentation:You can see a couple of implementations on
example(print.trellis)
, but here's one that I prefer:The code above gives you this figure:
As you can see,
split
takes four parameters. The last two refer to the size of your frame (similar to whatmfrow
does), whereas the first two parameters position your plot into thenx
byny
frame.