Skip to content

Better respect theme settings when drawing coord_sf() panel grid #3113

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

Merged
merged 4 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ggplot2 3.1.0.9000

* `coord_sf()` graticule lines are now drawn in the same thickness as
panel grid lines in `coord_cartesian()`, and seting panel grid
lines to `element_blank()` now also works in `coord_sf()`
(@clauswilke, #2991, #2525).

* `geom_hline()`, `geom_vline()`, and `geom_abline()` now throw a warning if the user supplies both an `xintercept`, `yintercept`, or `slope` value and a mapping (@RichardJActon, #2950).

* `scale_color_continuous()` now points at `scale_colour_continuos()` so that it
Expand Down
17 changes: 12 additions & 5 deletions R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,18 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,

render_bg = function(self, panel_params, theme) {
el <- calc_element("panel.grid.major", theme)
line_gp <- gpar(col = el$colour, lwd = el$size, lty = el$linetype)
grobs <- c(
list(element_render(theme, "panel.background")),
lapply(sf::st_geometry(panel_params$graticule), sf::st_as_grob, gp = line_gp)
)

# we don't draw the graticules if the major panel grid is
# turned off
if (inherits(el, "element_blank")) {
grobs <- list(element_render(theme, "panel.background"))
} else {
line_gp <- gpar(col = el$colour, lwd = el$size*.pt, lty = el$linetype)
grobs <- c(
list(element_render(theme, "panel.background")),
lapply(sf::st_geometry(panel_params$graticule), sf::st_as_grob, gp = line_gp)
)
}
ggname("grill", do.call("grobTree", grobs))
},

Expand Down