-
Notifications
You must be signed in to change notification settings - Fork 119
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
Colouring the groups is not consistent if data for grouping level is missing #445
Comments
It's been years since we've run across a fundamental issue like this one. 😱 Thank you for starting the conversation! Ok. So let's back up and see what's happening with ggplot2... If we look at very simplified code of one of the panels in question, we get code similar to: ggplot(iris, aes(Petal.Length, fill = Species)) + geom_histogram()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning message:
#> Removed 50 rows containing non-finite values (stat_bin). Rightfully so, there should be three colors in the legend, even if there is no data being plotted... as the levels of the data say that a color choice should exist. But, we have the warning message of Maybe related: tidyverse/ggplot2#4567 Do you know how we could write a standard ggplot2 code that would have the correct legend? If so, then we can adjust the |
I found a way of manually setting group colors but it is a bit messy: ` ggplot(iris, aes(Petal.Length, fill = Species, )) + geom_histogram() + scale_fill_manual(values=mycolors) but this is not 100% transferrable to ggpairs, and it does not get rid of the error message. The upper diagonal panel text is not coloured by groups any more.
|
In ggplot2, adding
|
I'll have to work on the correlation plots. There's a lot of data transformations beforehand that make leveraging the original data harder, but not impossible! TODO:
|
Thank you for your efforts! |
Something to note is the group correlations remain colored here with Using
with Another workaround, which seems likely to be fragile, is to hijack the color map so discrete color works like manual color,
in which case colors do flow to group correlation text, provided no color is specified in |
Have you made any progress on this issue ? :) |
I am having issue with ggpairs, if one value for a grouping levels is missing, the colours are not consistent. Is there a way to circumvent this?
Here is an example:
The text was updated successfully, but these errors were encountered: