-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorcoord ๐บ๏ธ
Description
In ggplot2 3.1.0, coord_sf()
drops axis labels if graticules don't extend all the way to the plot boundary. This is a regression from 3.0.0. A reprex follows.
library(ggplot2)
world <- sf::st_as_sf(rworldmap::getMap(resolution = "low"))
ggplot(world) + geom_sf() + theme_bw() + coord_sf()
ggplot(world) + geom_sf() + theme_bw() + coord_sf(expand = FALSE)
Created on 2018-11-08 by the reprex package (v0.2.1)
This bug was introduced by me when I wrote code such as the following, to calculate intersection points between the graticules and the plot boundaries:
Line 592 in 15ddc22
id1 <- c(id1, which(graticule$type == panel_params$label_axes$top & graticule$y_start > 0.999)) |
I did not consider that the plot range could extend beyond the physical limits of the earth. I'll have to ponder what the options are. One option might be to make the tolerance configurable. (I hardcoded 0.001.) Another option might be to base the tolerance on the expansion factors used for the x and y scales.
prncevince
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorcoord ๐บ๏ธ