Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ggplot2 (development version)

* The `legend.key` theme element is set to inherit from the `panel.background`
theme element. The default themes no longer set the `legend.key` element.
This causes a visual change with the default `theme_gray()` (#5549).

* Lines where `linewidth = NA` are now dropped in `geom_sf()` (#5204).

* New `guide_axis_logticks()` can be used to draw logarithmic tick marks as
Expand Down
15 changes: 2 additions & 13 deletions R/theme-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ theme_grey <- function(base_size = 11, base_family = "",
legend.spacing.x = NULL,
legend.spacing.y = NULL,
legend.margin = margin(half_line, half_line, half_line, half_line),
legend.key = element_rect(fill = "grey95", colour = NA),
legend.key = NULL,
legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
Expand Down Expand Up @@ -266,8 +266,6 @@ theme_bw <- function(base_size = 11, base_family = "",
panel.grid.minor = element_line(linewidth = rel(0.5)),
# contour strips to match panel contour
strip.background = element_rect(fill = "grey85", colour = "grey20"),
# match legend key to background
legend.key = element_rect(fill = "white", colour = NA),

complete = TRUE
)
Expand Down Expand Up @@ -340,9 +338,6 @@ theme_light <- function(base_size = 11, base_family = "",
# match axes ticks thickness to gridlines and colour to panel border
axis.ticks = element_line(colour = "grey70", linewidth = rel(0.5)),

# match legend key to panel.background
legend.key = element_rect(fill = "white", colour = NA),

# dark strips with light text (inverse contrast compared to theme_grey)
strip.background = element_rect(fill = "grey70", colour = NA),
strip.text = element_text(
Expand Down Expand Up @@ -382,9 +377,6 @@ theme_dark <- function(base_size = 11, base_family = "",
# match axes ticks thickness to gridlines
axis.ticks = element_line(colour = "grey20", linewidth = rel(0.5)),

# match legend key to panel.background
legend.key = element_rect(fill = "grey50", colour = NA),

# dark strips with light text (inverse contrast compared to theme_grey)
strip.background = element_rect(fill = "grey15", colour = NA),
strip.text = element_text(
Expand Down Expand Up @@ -442,9 +434,6 @@ theme_classic <- function(base_size = 11, base_family = "",
# show axes
axis.line = element_line(colour = "black", linewidth = rel(1)),

# match legend key to panel.background
legend.key = element_blank(),

# simple, black and white strips
strip.background = element_rect(fill = "white", colour = "black", linewidth = rel(2)),
# NB: size is 1 but clipped, it looks like the 0.5 of the axes
Expand Down Expand Up @@ -586,7 +575,7 @@ theme_test <- function(base_size = 11, base_family = "",
legend.spacing.x = NULL,
legend.spacing.y = NULL,
legend.margin = margin(0, 0, 0, 0, "cm"),
legend.key = element_rect(fill = "white", colour=NA),
legend.key = NULL,
legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/theme-elements.R
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
legend.spacing = el_def("unit"),
legend.spacing.x = el_def(c("unit", "rel"), "legend.spacing"),
legend.spacing.y = el_def(c("unit", "rel"), "legend.spacing"),
legend.key = el_def("element_rect", "rect"),
legend.key = el_def("element_rect", "panel.background"),
legend.key.height = el_def(c("unit", "rel"), "legend.key.size"),
legend.key.width = el_def(c("unit", "rel"), "legend.key.size"),
legend.text = el_def("element_text", "text"),
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/guides/left-aligned-legend-key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/theme/theme-classic-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/theme/theme-classic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/theme/theme-gray-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/theme/theme-gray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/theme/titles-aligned-to-entire-plot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.