add.grid: add.grid

View source: R/common.R

add.gridR Documentation

add.grid

Description

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.

Usage

add.grid(
  mode = "xy",
  fg.col = "white",
  bg.col = "ivory2",
  lwd.major = 3,
  lwd.minor = 1,
  bty = "o"
)

Arguments

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.

Examples

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


ArtPoon/ggfree documentation built on July 11, 2024, 11:15 a.m.