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

Coord sf breaks fallback #6232

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

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #2985.

Briefly, if the graticule lines are horizontal or vertical, we could infer where the tickmark should be placed. This PR doesn't solve axis labels placement for all projections, but it does fix a common painpoint.

For WGS84, it solves the problem:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

world <- sf::st_as_sf(rworldmap::getMap(resolution = "low"))
p <- ggplot(world) + 
  geom_sf()
p

For the Robinson projection, it can place the y-axis labels and a single label at 0 degrees.

p + coord_sf(crs = "+proj=robin")

For this projection, no labels can be placed because all graticule lines are curved.

p + coord_sf(crs = "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000")

The IGH projection only gets y-axis labels because all x-graticule lines are not straight.

p + coord_sf(crs = "+proj=igh")

Created on 2024-12-11 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.

coord_sf() drops axis labels if graticules don't extend all the way to the plot boundary
1 participant