Skip to contents

Provides crop_to() to zoom in to a subset of a data frame, and view_box() to annotate the zoomed-in region on the full plot.

Usage

crop_to(subset, data, ...)

view_box(subset, data)

Arguments

subset

An indexing expression to select rows from data. Tidy-evaluted in the context of data.

data

An sf data frame.

...

Additional arguments passed to coord_sf().

Value

crop_to() returns a coord_sf() object to be added to a ggplot. view_box() returns a geom_rect() layer to be added to a ggplot.

Examples

library(ggplot2)
data(oregon)

ggplot(oregon, aes(fill = ndv / (ndv + nrv))) +
    geom_sf(size = 0) +
    scale_fill_538(name = "") +
    view_box(county == "Multnomah", oregon) +
    theme_map()


ggplot(oregon, aes(fill = ndv / (ndv + nrv))) +
    geom_sf(size = 0) +
    scale_fill_538(name = "") +
    crop_to(county == "Multnomah", oregon) +
    theme_map()