-
Notifications
You must be signed in to change notification settings - Fork 25
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
allow slab subgroups to have different widths #150
Comments
Hmm yeah, this doesn't really work at the moment because slabinterval enforces each subgroup to have the same width. E.g. this is the closest I could get (notice only one group correctly covers the data points along the x axis): set.seed(1234)
data.frame(
g = c("a","b"),
var1 = rnorm(1000, 1:2),
var2 = rnorm(1000)
) |>
ggplot(aes(
x = ave(var1, g, FUN = min),
y = var2,
fill = g,
width = ave(var1, g, FUN = \(x) diff(range(x)))
)) +
stat_gradientinterval(scale = 1, side = "right", justification = 0, fill_type = "gradient", color = NA) +
geom_point(aes(x = var1), pch = 21, alpha = 0.5) I'm not entirely sure it would be straightforward to relax that constraint on equal widths, as it is used to ensure dodging works properly (unless I'm misremembering), but I can look into it... it's possible I can allow it to be overridden if it's set manually. |
I'm happy you were able to parse my vague issue into a reprex that precisely reflects my intended outcome, thanks for the effort. For now resolving this does not have priority for me, I'll just tweak the figure manually if needed. But let's leave the issue open to see if there's further interest---or otherwise close it and explain that it may be beyond the scope of the package for now ;-). |
:) I don't mind leaving it open; I might take a stab at fixing it eventually or maybe someone will wander along who's interested. |
I have some data where I average many y-values together over a large range of x-values, and I want to be able to draw a gradient that spans the range of x-values.
As a workaround I have been able to just set a very large
width
and then post-process the gradients in Inkscape.I have also tried passing the variable as a width aesthetic, but this still remained the same for each bin.
Here's an image illustrating the desired outcome after specifying either the
width
or anxmin
andxmax
as aesthetics:The text was updated successfully, but these errors were encountered: