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

Merged
merged 4 commits into from
Nov 11, 2024

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

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 6606390 into tidyverse:main Nov 11, 2024
13 checks passed
@teunbrand teunbrand deleted the skip_empty_graticule branch November 11, 2024 13:08
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
2 participants