-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Guide colorsteps creates an ugly, large NA box #3876
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
Comments
For comparison, this is what it looks like with library(ggplot2)
set.seed(4393)
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(dsmall, aes(x, y)) +
geom_density_2d_filled(aes(fill = after_stat(level_high))) +
scale_fill_viridis_c(guide = "legend") Created on 2020-03-09 by the reprex package (v0.3.0) |
I’m pretty sure this is due to the recent fix to make NA work with binning. In my point of view, NA shouldn’t be shown in the legend at all. I’ll look into a fix |
Hmm, this might be my oversight, but the CRAN version seems to behave the same... I'm a bit confused. Is it intended to use library(tidyverse)
sessioninfo::package_info("ggplot2", dependencies = FALSE)
#> package * version date lib source
#> ggplot2 * 3.3.0 2020-03-05 [1] CRAN (R 3.6.3)
#>
#> [1] /home/yutani/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/lib/R/library
data(airquality)
airQ <- filter_all(airquality, ~!is.na(.))
ggplot(airQ, aes(x = Solar.R, y = Temp)) +
stat_density_2d(aes(fill = after_stat(level)), geom = "polygon") +
scale_fill_viridis_c(guide = "coloursteps") Created on 2020-03-10 by the reprex package (v0.3.0) library(ggplot2)
set.seed(4393)
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(dsmall, aes(x, y)) +
geom_density_2d_filled(aes(fill = after_stat(level_high))) +
scale_fill_viridis_b(guide = "colorsteps") Created on 2020-03-10 by the reprex package (v0.3.0) |
It looks to me like with the binned scale, we're binning twice, once to make the contours and once to assign the colors. Notice how we have more contour bands than colors. library(ggplot2)
set.seed(4393)
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(dsmall, aes(x, y)) +
geom_density_2d_filled(aes(fill = after_stat(level_high)), color = "white") +
scale_fill_viridis_b(guide = "colorsteps") Created on 2020-03-10 by the reprex package (v0.3.0) |
Thanks, I see. |
Yeah. There are some stats that provide the binning themselves because they need access to the unbinned data. These should not be mixed with the binning scales |
Technically another issue against my PR #3864. I made this figure yesterday and I thought the guide looks ugly. Why is the box representing
NA
so large? ShouldNA
be shown at all by default? Should it maybe be shown with a little gap? Is this correct at all?Created on 2020-03-09 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: