-
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
Error when combining scale_color_manual and guide_legend (override.aes) in v3.3.4 #4511
Comments
This issue also occurs in the newest release version 3.3.4. As described, all colors in |
This change may have been added when fixing issue 3451 to allow the This was done in pull request #4471. There I can see the following lines added to if (is.null(limits)) {
limits <- names(values)
} Changing the limits to the value names in this scenario, where the vector of names contains more values than the plotting dataset, could cause this new behavior. This approach would appear to potentially bypass the I haven't thought of a straightforward fix; maybe there is a way to set the In terms of the original issue with override.aes = list(alpha = 0.6,
size = 6) |
@aosmith16 Thanks for tracking this down. Yes, this is the problem. Not sure how to fix it either off the top of my head. |
I've found setting |
* issue introduced in tidyverse#4471 * potential solution for tidyverse#4534 and tidyverse#4511 * add extra tests
* issue introduced in tidyverse#4471 * potential solution for tidyverse#4534 and tidyverse#4511 * add extra tests
Oh, that new feature broke a lot of my plots too. I think the old behaviour was better, where one could define a list of colors to be used in all kinds of plots, without needing to add additional paramters to the scale_ functions. |
To expand a bit on the workaround; scales can take functions or values as the limits. The function takes the computed (standard) limits as input. Using Lines 135 to 137 in de5d63f
Which skips grabbing the limits from the named manual values. In addition: perhaps, if the aim of #4471 was to allow fewer elements, then the line above could be changed to: if (is.null(limits)) {
force(values)
limits <- function(x) {intersect(x, names(values))}
} Which appears to be an easier solution than the one proposed in #4547, wherein the |
Fixed by #4619 |
With the reprex below, I got the following error when changing the
alpha
andsize
values usingguide_legend (override.aes)
. Note that the current CRAN version (v3.3.3) worked without any error.Reprex (data taken from this issue)
Set up manual color scale
Filter out group "A"
Legend for group "A" shows up even though we don't have it anymore (this wasn't the problem with v3.3.3 CRAN)
Created on 2021-06-14 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: