-
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
Feature request: enable expand arguments for continuous color and fill scales. #3508
Comments
(I talked with atusy outside of GitHub) Sorry, probably my explanation was not exact; you don't need library(grid)
g <- matrix(hcl(0, 100, c(0, 100)),
nrow=2, ncol=1)
# interpolated
grid.newpage()
grid.raster(g, x = 0.25, width = 0.5, height = 1)
grid.raster(g, x = 0.75, width = 0.5, height = 1, interpolate = FALSE) Created on 2019-08-30 by the reprex package (v0.3.0) So, the short answer would be "you don't need @thomasp85 @clauswilke |
I was confused by this bug report because I'm certain the color scale is not expanded. The trick to fix this issue is to increase the value of library(ggplot2)
x <- c(0, 1)
# default nbin = 20, looks like the color scale is expanded
ggplot(data = data.frame(x = x), aes(x, x, color = x)) +
geom_point() +
scale_color_gradient(
breaks = x, limits = x,
guide = guide_colorbar(
barheight = grid::unit(1, "npc") - grid::unit(4, "line"),
ticks.linewidth = 2
)
) # with nbin = 200, the effect disappears
ggplot(data = data.frame(x = x), aes(x, x, color = x)) +
geom_point() +
scale_color_gradient(
breaks = x, limits = x,
guide = guide_colorbar(
barheight = grid::unit(1, "npc") - grid::unit(4, "line"),
ticks.linewidth = 2,
nbin = 200
)
) Created on 2019-08-29 by the reprex package (v0.3.0) |
Ah, thanks! Since this is fundamentally a matter of resolution,
Agreed. Do you think we can increase the default? It will break visual tests here and there, but I feel it's worth breaking. |
I think that's a question for @hadley. |
It's fine with me. |
Thanks, then I'll create a PR for this. (Yet to investigate how many |
BTW, I don't quite understand what the document of
In terms of "smoothness", at least the examples on the pkgdown site look the same as the Maybe we need another example with so complex colour palettes that the interpolation of Or, does this mean the colourbar should not be interpolated on |
I still don't see what the doc of |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Unlike scales for continuous x or y (e.g.,
scale_x_continuous
), those for color or fill (e.g.,scale_color_gradient
) is not supportingexpand
option.At least, I want
expand = c(0, 0)
to work so that color bars exactly represents the range of color or fill mappings.The example below shows that range of color bar is wider than the range specified in
limits
argument even ifexpand = c(0, 0)
is specified.@yutannihilation figured out this is caused by
ggplot2/R/guide-colorbar.r
Line 336 in 047b528
Created on 2019-08-29 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: