add.grid | R Documentation |
add.grid
draws a filled background in the plot region and
lines for the major and minor ticks, in the style of ggplot2. Because
generic plot drawing adds objects in layers, add.grid
should be called
*after* drawing an empty plot region, and *before* adding any points or lines.
add.grid(
mode = "xy",
fg.col = "white",
bg.col = "ivory2",
lwd.major = 3,
lwd.minor = 1,
bty = "o"
)
mode: |
'xy' displays both horizontal and vertical lines, 'x' horizontal only and 'y' vertical only. Any string without 'x' or 'y' gives plain background. |
fg.col: |
colour for grid lines in foreground |
bg.col: |
colour for grid background |
lwd.major: |
line width for major grid lines |
lwd.minor: |
line width for minor grid lines. Set to 0 to suppress. |
x <- rnorm(100)
y <- rnorm(100)
plot(NA, xlim=range(x), ylim=range(y)) # prepare empty plot
add.grid()
points(x, y, pch=21, bg='white') # now draw the data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.