Skip to contents

autoplot() (from ggplot2) for a pic() object: georeferences the drawing with rpic_sf() and draws it with rpic_layers() — fills, strokes and labels as pic drew and placed them — on a blank theme. The result is an ordinary ggplot: add scales, a theme or more layers with + (a layer added this way goes on top of the drawing; for a basemap under it, build the plot from rpic_layers() directly, as vignette("maps") does).

Usage

# S3 method for class 'rpic_source'
autoplot(object, ..., linewidth = 0.4, text_size = 3)

Arguments

object

a pic() object whose source georeferences itself (geo_lon/geo_lat, control points) or is given anchor/features in ....

...

passed to rpic_sf() (anchor, scale, bearing, frame, features, ...).

linewidth

line width of the shapes, in ggplot2 units (mm). NULL draws each shape at pic's own width (the stroke_width column, points, 0.8 by default).

text_size

size of the labels, in ggplot2 units (mm).

Value

a ggplot object.

Requirements

Needs ggplot2 and sf.

Examples

if (requireNamespace("ggplot2", quietly = TRUE) &&
    requireNamespace("sf", quietly = TRUE)) {
  p <- pic('geo_lon = -34.8711; geo_lat = -8.0631; geo_scale = 1000
  C: circle rad 2 at (0, 0) dashed fill 0.97
  dot at C.c rad 0.04
  "2 km" above at 0.5 <C.c, C.e>')
  ggplot2::autoplot(p)
}