addGrid: Add a Grid to a Plot

View source: R/addGrid.R

addGridR Documentation

Add a Grid to a Plot

Description

This function adds a grid to an existing plot (like box()). User can specify coordinates on x- and/or y-axis where to draw vertical and/or horizontal lines respectively. User can also color the background of the plot area and add a box around this area (if required).

Usage

addGrid(
  at_x,
  at_y,
  col = NA,
  border = "black",
  lwd = 1,
  lty = 1,
  box = FALSE,
  ...
)

Arguments

at_x, at_y

coordinates on the x and y-axis where to draw lines.

col

the color of the background.

border

the color of lines (and box).

lwd

the width of lines (see par()).

lty

the type of lines (see par()).

box

a boolean. If TRUE add a box around the plot area.

...

other graphical parameters as in par().

Details

If user does not specify at_x and at_y, the grid is aligned with the tick marks on the corresponding default axes (computed by axTicks).

Author(s)

Nicolas CASAJUS, nicolas.casajus@gmail.com

Examples

maps::map()
addGrid()
addGrid(box = TRUE)
addGrid(col = "#ff000044", border = "green", box = TRUE)

maps::map()
addGrid(at_x = axTicks(1), border = "blue", lwd = 2)
addGrid(at_y = axTicks(2), border = "red")
addGrid(at_x = NULL, at_y = NULL, lwd = 3, box = TRUE)


inSileco/graphicsutils documentation built on Sept. 12, 2022, 11:13 p.m.