Closed
Description
Argument passed to formal parameter drop
is ignored, and unused factor levels are not dropped from the legend as indicated in the documentation. This used to work in the past. 3.3.6, 3.3.5, 3.3.4 are broken, 3.3.3 is good.
Reprex for version 3.3.6 (3.3.5, 3.3.4). drop = TRUE
ignored in the manual scale, but obeyed by the default scale.
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.3.6'
my.df <- data.frame(x = rnorm(50),
y = rnorm(50),
outcome = factor(sample(letters[1:3], 50, replace = TRUE),
levels = letters[1:4]))
# level "d" is dropped
ggplot(my.df, aes(x, y, colour = outcome)) +
geom_point()
# level "d" is not dropped
ggplot(my.df, aes(x, y, colour = outcome)) +
geom_point() +
scale_colour_manual(values = c(a = "red", b = "green", c = "blue", d = "orange"),
drop = TRUE)
Created on 2022-09-04 with reprex v2.0.2
Reprex for version 3.3.3. drop = TRUE
obeyed consistently.
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.3.3'
my.df <- data.frame(x = rnorm(50),
y = rnorm(50),
outcome = factor(sample(letters[1:3], 50, replace = TRUE),
levels = letters[1:4]))
# level "d" is dropped
ggplot(my.df, aes(x, y, colour = outcome)) +
geom_point()
# level "d" is dropped as expected
ggplot(my.df, aes(x, y, colour = outcome)) +
geom_point() +
scale_colour_manual(values = c(a = "red", b = "green", c = "blue", d = "orange"),
drop = TRUE)
Created on 2022-09-04 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels