-
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_steps produces unevenly spaced legend when limits are set #4019
Comments
Thanks, confirmed. This seems a bug that library(ggplot2)
library(patchwork)
df <- data.frame(x = 0:4)
p <- ggplot(df, aes(x, 0)) +
geom_point(aes(fill = x), pch = 21, size = 80)
p1 <- p +
scale_fill_steps(low = "white", high = "red", limits = c(1, 3)) +
ggtitle("step")
p2 <- p +
scale_fill_gradient(low = "white", high = "red", limits = c(1, 3)) +
ggtitle("gradient")
p1 / p2 Created on 2020-06-13 by the reprex package (v0.3.0) |
This is intentional. Binning scales squashes out of bounds values by default, whereas continuous scales censor them |
Aw, I see. Sorry, I misunderstood the behaviour. library(ggplot2)
df <- data.frame(x = 0:4)
ggplot(df, aes(x, 0)) +
geom_point(aes(fill = x), pch = 21, size = 80) +
scale_fill_steps(low = "white", high = "red", limits = c(1, 3), oob = scales::censor) Created on 2020-06-13 by the reprex package (v0.3.0) Do you think this issue is something that we should fix? I'm wondering if we need some tweaks like what #4006 did for contours. |
The oob behaviour is easily changeable. But the spacing in the binned scale legend is unexpected and the fix is not intuitive. I've found that setting the limits to slightly offset from my desired limits fixes this. Still, it's not clear why the binned legend spaces itself in this strange way. library(ggplot2)
df <- data.frame(x = 0:4)
ggplot(df, aes(x, 0)) +
geom_point(aes(fill = x), pch = 21, size = 80) +
scale_fill_steps(low = "white", high = "red", limits = c(1.001, 2.999)) Created on 2020-06-14 by the reprex package (v0.3.0) |
When setting the limits of
scale_fill_steps()
, the fill brackets in the legend becomes unevenly spaced. It's not clear why or how this happens.Created on 2020-05-22 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: