StatsPlots.jl
StatsPlots.jl copied to clipboard
Add keyword to put space between bars/boxes/violins in groups
As discussed in #192:
Default:
Would like to give users the option to put a space between:
I'm facing the same issue in StatsMakie, any idea what a good keyword would be? I'm thinking shrink = 0.8
but maybe there are better options.
R uses space
Does it make sense to use barwidth
for this?
Possibly but is the bar width and the spacing not two slightly different things you'd like independent control of?
I don't think they can be controlled seperately within one series. A bigger barwidth implies smaller spacing and vice versa, no?
I don't think they can be controlled seperately within one series. A bigger barwidth implies smaller spacing and vice versa, no?
In practice for a single series only one quantity is relevant: space
is only effective when no explicit width is given and I think it makes a difference in terms of API. For example, let's say I do:
bar(x, y)
I would get a barwidth of 0.8*minimum(diff(x))
. If I want to increase that value systematically across plots, I could do width = 0.9*minimum(diff(x))
but that's a bit clumsy, so maybe it'd be easier to have:
space --> 0.2
width --> (1-space)*minimum(diff(x))
And the user can manipulate space if needed (space = 0
for example)
R uses
space
Is it multiplicative or additive? Meaning, would it be something like the above width --> (1-space)*minimum(diff(x))
or more of a width --> minimum(diff(x)) - space
? I'd prefer the first one but was curious to know what's the default in other environments.
In R it's additive. So it shifts the position of the center of the bar on the x axis by bar-width + space for each new bar.
I don't think they can be controlled separately within one series. A bigger barwidth implies smaller spacing and vice versa, no?
Not really...

or for bars

Yeah there are a lot of somewhat-independent-but-interconnected factors - space-within-group , space-among-groups, bar-width and distance-between-group-centers (the x ticks). Different plotting packages and languages have different implementations. Really not sure what I find most intuitive, though I'm quite sure it is not shrink
:-p
though I'm quite sure it is not shrink
Agree!
Yeah there are a lot of factors - space-within-group , space-among-groups, bar-width and distance-between-group-centers (the x ticks)
Yeah, it seems complex, but I actually think it only really requires additional control over 2 things - bar width and space-within-group (or space-among-groups, I'm not entirely sure what you mean with that - I'm referring to the space between the blue and purple bars in my example). The x values determines distance between group centers (it seems sensible to default to integers for categorical variables, but allow overrides).
That is, assuming we're expecting it all to be uniform across groups. If not, then it will definitely get much more complicated... I can imagine when one might want to change that, but I'm not sure I've seen it in the wild...
Any progress on this?