Learn R Programming

terra (version 1.8-5)

add_grid: add a grid to a map made with terra

Description

Adaptation of grid that allows adding a grid to a map. This function will place the legend in the locations within the mapped area as delineated by the axes.

Also see graticule

Usage

add_grid(nx=NULL, ny=nx, col="lightgray", lty="dotted", lwd=1)

Arguments

nx, ny

number of cells of the grid in x and y direction. When NULL, as per default, the grid aligns with the tick marks on the corresponding default axis (i.e., tickmarks as computed by axTicks). When NA, no grid lines are drawn in the corresponding direction

col

character or (integer) numeric; color of the grid lines

lty

character or (integer) numeric; line type of the grid lines

lwd

non-negative numeric giving line width of the grid lines

See Also

graticule, add_legend, add_box, add_grid, add_mtext

Examples

Run this code
v <- vect(system.file("ex/lux.shp", package="terra"))
plot(v)
add_grid()

Run the code above in your browser using DataLab