Is there a command to easily add a grid onto an R plot?
Grid graphics is a low-level system for plotting within R and is as a separate system from base R 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.
A “plotting grid” is a physical chart used to lay out the components of a story in a visual way. It often looks a lot like this: This is a photo of the actual ratty old plotting grid I use. The plotting grid can be useful to anyone at any stage of writing.
The grid command seems to draw grid lines where-ever it feels like. I usually use abline to put lines exactly where I want them. For example,
abline(v=(seq(0,100,25)), col="lightgray", lty="dotted") abline(h=(seq(0,100,25)), col="lightgray", lty="dotted")
Good luck!
See help(grid)
which works with standard graphics -- short example:
R> set.seed(42) R> plot(cumsum(rnorm(100)), type='l') R> grid()
The ggplot2 package defaults to showing grids due to its 'Grammar of Graphics' philosophy. And lattice has a function panel.grid()
you can use in custom panel functions.
By the way, there are search functions for help as e.g. help.search("something")
and there is an entire package called sos to make R web searches more fruitful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With