Skip to content
Open
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Bug fixes

* Fixed regression where `NULL`-aesthetics contributed to plot labels too
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
(@mitchelloharawild, #6609).
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
Expand Down
5 changes: 4 additions & 1 deletion R/aes-evaluation.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ strip_stage <- function(expr) {
make_labels <- function(mapping) {
default_label <- function(aesthetic, mapping) {
# e.g., geom_smooth(aes(colour = "loess")) or aes(y = NULL)
if (is.null(mapping) || is.atomic(mapping)) {
if (is.null(mapping)) {
return(structure(aesthetic, fallback = TRUE))
}
if (is.atomic(mapping)) {
return(aesthetic)
}
mapping <- strip_stage(mapping)
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-aes-calculated.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ test_that("make_labels() deparses mappings properly", {
expect_match(x_lab, "...$")
# if the mapping is a literal or NULL, the aesthetics is used
expect_identical(make_labels(aes(x = 1)), list(x = "x"))
expect_identical(make_labels(aes(x = NULL)), list(x = "x"))
# NULL labels should only be used as fallback labels
expect_identical(
make_labels(aes(x = NULL)),
list(x = structure("x", fallback = TRUE))
)
})

test_that("staged aesthetics warn appropriately for duplicated names", {
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-aes.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ test_that("quosures are squashed when creating default label for a mapping", {
test_that("labelling doesn't cause error if aesthetic is NULL", {
p <- ggplot(mtcars) + aes(x = NULL)
labels <- ggplot_build(p)@plot@labels
expect_identical(labels$x, "x")
# NULL labels should only be used as fallback labels
expect_identical(labels$x, structure("x", fallback = TRUE))
})

test_that("aes standardises aesthetic names", {
Expand Down
Loading