-
Notifications
You must be signed in to change notification settings - Fork 2k
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
scale_fill_manual(drop = FALSE)
results in missing key aesthetics
#5728
Comments
Hi there, thanks for the report! This is indended behaviour from the 3.5.0 update: if your data doesn't contain the level, the key isn't rendered for that layer by default. To render the keys for non-existing data, you should set Lines 36 to 38 in bc3e401
And communicated in the release blog: https://www.tidyverse.org/blog/2024/02/ggplot2-3-5-0-legends/#awareness There is a separate issue for making this clearer in the documentation of scales, see #5715. |
@teunbrand thanks for the help. I agree that improving the documentation would help. I have come across some other unexpected (for me at least) behavior that I wanted to ask about. This may be an issue with the package
The following plot works as expected. Some points on top of a raster, with just the legend for the points.
When I set
My
|
Setting |
This is a very unintuitive change, I feel like |
This change is to remove the need for setting very complicated and tailored |
You still need it to include unobserved levels. |
Would it not make sense to also include the colours associated with those unobserved levels? (especially for consistency with other plots where the levels are observed) |
Yes and no. Yes it makes intuitive sense, but no, it destroys the ability to control this at the geom level. |
I agree controlling this at the geom level makes sense, but currently the behaviour of |
I can emphasise with the annoyance of this change for your particular use cases, but making the requested change would in practice make it impossible to have |
Should the help/documentation of scale_XXX_manual be updated to reference this change in behaviour? Noting that the behaviour of |
The documentation was adjusted to reflect this change better in #5732 and will be included in the next release. |
Alright with 3.5.1 now released and we don't have the intent to change this, I believe it is time to close this issue. |
``` # tidyverse/ggplot2#5728 (comment) show.legend = c(colour = TRUE)) + ```
This is an issue that popped up for me when updated from version 3.4.4 to 3.5.0.
VERSION 3.4.4
Both of these functioned as I would expect.
drop = TRUE
drop = FALSE
VERSION 3.5.0
drop = TRUE
is the same, as expected.drop = FALSE
adds the missing levels to the legend, but the keys are empty.The text was updated successfully, but these errors were encountered: