A few other graphics packages, including the lattice package, are also built using grid graphics. Grid graphics functions can also be used to create almost any imaginable plot from scratch. In particular, ggplot objects can be added to larger plot output using grid graphics functions, and grid graphics functions can be used to add elements to ggplot objects. The ggplot2 package is built on top of grid graphics, so the grid graphics system “plays well” with ggplot2 objects. For example, if you want to quickly plot a scatterplot of data, you should use ggplot2, but if you want to create a plot with an inset plot with tilted axis labels, then you may need to go to grid graphics. By “low-level,” we mean that grid graphics functions are typically used to modify very specific elements of a plot, rather than being functions to use for a one-line plotting call. Grid graphics is a low-level system for plotting within R and is as a separate system from base R graphics. You can even include mathematical annotation on ggplot objects using ggplot2 functions (see for some examples) and change coordinate systems (for example, a pie chart can be created by using polar coordinates on a barchart geom). For example, as described in previous sections, you can use ggplot2 functions to change the theme of a plot (and you can also change specific elements of the theme for a plot), to customize the colors used within the plot, and to create faceted “small multiple” graphs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |