ggplot2
ggplot2 copied to clipboard
Skip viewscales if graticule is empty
This PR aims to fix #6052.
Briefly, ggplot2 got stuck when graticules are empty. In this PR, we skip computation of axis ticks when the graticule is empty.
Reprex:
library(ggplot2)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
# Data with out-of-bounds values
df <- st_sf(
g = st_sfc(st_point(c(-600, 1200))),
crs = 4326
)
# Old behaviour
ggplot(df) + geom_sf()
#> Warning in st_is_longlat(x): bounding box has potentially an invalid value
#> range for longlat data
#> Error: Invalid index: field name 'x_start' not found
devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
# New behaviour
ggplot(df) + geom_sf()
#> Warning in st_is_longlat(x): bounding box has potentially an invalid value
#> range for longlat data

Created on 2024-08-27 with reprex v2.1.1