使用 R 中的网格绘图系统制作可调整大小的图
最近我读到了 R 中的网格绘图系统。它非常灵活,熟练掌握它应该能够制作非常复杂的图表。但是我还没有找到任何好地方可以让我绘制一个可以调整大小的图表?问题如下:如何在R
中使用grid
图形系统以使最终输出实际上可以调整大小?
Recently I read about the grid graphing system in R. It is very flexible and with its mastery one should be able to make very sophisticated graphs. However I have not found any good place that will allow me to plot a graph that is also re-sizable? The question is as follows: How do you use grid
graphing system in R
so that the final output is actually resizable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是不直接使用夹点绘图系统,而是使用它的
lattice
接口。据我所知,lattice 包随 R 一起安装,并为底层的网格图(基于网格的图)形成了一个非常灵活的接口。 Lattice 还允许您直接操作网格,因此实际上对于最复杂的图形来说,这将是您所需要的。如果您确实要使用网格绘图系统本身,则必须使用正确的坐标系才能使其可扩展。 “native”、“npc”(标准化父坐标)或“snpc”(方形标准化父坐标)都允许您重新缩放图形,因为它们给出相对于当前视口的大小(或其一个方面)的坐标。
为了充分利用这些,请确保您非常了解视口的概念。我必须承认我还有很多东西需要学习。如果你真的想继续下去,我可以推荐这本书 Paul Murrell 的 R Graphics
仔细阅读该书的第 5 章。您还可以从示例的 R 代码中学到很多东西,这些代码也可以在 此页面
给您一个:
完美可扩展。如果您查看
grid.circle
的帮助页面,您会发现default.units="npc"
选项。在本例中,这就是设置正确坐标系的位置。 比较。与不可扩展的
One way of doing so is not using the grip graphing system directly, but use the
lattice
interface to it. Thelattice
package comes installed with R as far as I know, and forms a very flexible interface to the underlyingTrellis
graphs, which are grid-based graphs.Lattice
also allows you to manipulate the grid directly, so in fact for most sophisticated graphs that will be all you need.If you really are going to work with the grid graphing system itself, you have to use the correct coordinate system for it to be scalable. Either "native", "npc" (Normalized Parent Coordinates) or "snpc" (Square Normalized Parent Coordinates) allow you to rescale a figure, as they give the coordinates relative to the size (or one aspect of it) of the current viewport.
In order to make full use of these, make sure you understand the concept of viewports very well. I have to admit that I still have a lot to learn about it. If you really want to get on with it, I can suggest the book R Graphics from Paul Murrell
Take a closer look at chapter 5 of that book. You can also learn a lot from the R code of the examples, which can also be found on this page
To give you one :
Perfectly scaleable. If you look at the help pages of
grid.circle
, you'll find thedefault.units="npc"
option. That's where in this case the correct coordinate system is set. Compare towhich is not scaleable.