-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
simplify plotting barplot by group #1223
Conversation
So this should supersede specifying |
I am not 100% happy with the status quo, where the user could set Another approach to make this work more robustly for categorical plots would be to not make In terms of simpler APIs, I imagine one could choose between:
Do you have preferences among these three options? 1. and 2. would also be fine from the AoG side if we implement the smarter |
I think there should be two values. The distance between bars (or the base width for each bar) and a shrink factor. The shrink factor could be relative to base width or absolute, I don't know what's more useful in situations where bars have different widths (probably absolute is easier there) but relative would give a consistent look independent of base width, so it's probably a better default. (We could make the absolute / relative flag another attribute actually). |
I'd be in favor of relative width = 1 (computed from the data if not provided)
shrink = 0.8 which results in actual There is also the |
Is it better to specify 0.8 or 0.2? I kind of tend towards 0.2, so the gap, because I guess having a gap is the reason to shrink the bar. But 0.8 would also be fine. Whatever we decide, the name should be chosen well. If we already have |
Ok, so this PR should:
Last doubt. I'm a bit unsure about |
for ranges, step(x) would be equal to minimum(diff(x)) no? I wonder if it would make sense to pick a vector of widths to account for cases in which the distances are different, but I'm not sure if that can be done well. I don't think minimum(diff) is too bad, probably is the right heuristic in common cases. |
Yes, I agree, I've kept I've added a mention in the docstrings that the width of the bar is If the docs / tests build fine, and we think the docstrings / attribute names are clear enough, this should be good to go. |
Can we merge this? |
I've just noticed that the Gantt example in the docs hadn't been updated for the |
merged in #1393 |
This allows specifying
x_distance
in a bar plot. It corresponds to the bar width + thex_gap
. The rationale is that we compute this from the data, assuming that bar width plusx_gap
should equalminimum(diffs(x))
, but in categorical data we just want that to be1
(otherwise things get problematic if in some group not all categories are present).With this PR, AlgebraOfGraphics can simply set
x_distance = 1
and all the user settings are automatically respected.Example
I'm actually wondering whether
x_distance = 1
(rather thanminimum(diffs(x))
) is a good default whenx
is not a range, but maybe setting these defaults should be done on the AlgebraOfGraphics side.