Learn R Programming

terra (version 1.8-80)

add_abline: add vertical and/or horizontal lines to a map made with terra

Description

Adaptation of abline that allows adding a horizonal or vertical lines to a map. This function will place the lines in the locations within the mapped area as delineated by the axes. It is meant to be used when you specifiy your own tick marks, such that add_grid does not work.

Also see graticule

Usage

add_abline(h=NULL, v=NULL, ...)

Arguments

See Also

add_grid, graticule, add_legend, add_box, add_grid, add_mtext

Examples

Run this code
v <- vect(system.file("ex/lux.shp", package="terra"))
atx <- seq(xmin(v), xmax(v), .1)
aty <- seq(ymin(v), ymax(v), .1)
plot(v, pax=list(xat=atx, yat=aty), ext=ext(v)+.2)
add_abline(h=aty, v=atx, lty=2, col="gray")

Run the code above in your browser using DataLab