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

* Fixed regression where `draw_key_rect()` stopped using `fill` colours
(@mitchelloharawild, #6609).
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
object is set to `labels` argument (@yutannihilation, #6617).

# ggplot2 4.0.0

Expand Down
2 changes: 1 addition & 1 deletion R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ as_unordered_factor <- function(x) {
size0 <- function(x) {
if (obj_is_vector(x)) {
vec_size(x)
} else if (is.vector(x)) {
} else if (is.vector(x) || is.expression(x)) {
length(x)
} else {
NULL
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-scales-breaks-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ test_that("labels don't have to match null breaks", {
expect_silent(check_breaks_labels(breaks = NULL, labels = 1:2))
})

test_that("labels accept expressions", {
labels <- parse(text = paste0(1:4, "^degree"))
sc <- scale_y_continuous(breaks = 1:4, labels = labels, limits = c(1, 3))

expect_equal(sc$get_breaks(), 1:4)
expect_equal(sc$get_labels(), as.list(labels))
})

test_that("labels don't have extra spaces", {
labels <- c("a", "abc", "abcdef")

Expand Down
Loading