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?
Recently I read about the grid graphing system in R. It is very flexible
Share
One way of doing so is not using the grip graphing system directly, but use the
latticeinterface to it. Thelatticepackage comes installed with R as far as I know, and forms a very flexible interface to the underlyingTrellisgraphs, which are grid-based graphs.Latticealso 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.