Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip viewscales if graticule is empty #6060

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Invalid index: field name 'x_start' not found
1 participant