-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Violins and Boxes in subplots oddly offset #3402
Comments
Upon further reflection, I realize why this is: there is nothing saying that the traces in the vertically-offset subplots are actually the same as the other ones and hence should be aligned. It only looks that way because they're coloured the same. I haven't tried it but I assume the same thing will happend with grouped bars. I think this calls for a new cross-trace argument allowing for grouping of groups or something. I've already used |
|
After further thought, given that we already do what seems like the right thing for |
After even further thought, I don't think that My proposal would be to introduce a new attribute for |
To be a bit clearer, here are two plots: same except that one is bar and one is violin. Right now there's no way to have the bars offset horizontally among the subplots if e.g. traces 0 and 2 (blue and green) are un-related. Similarly, there's no way to align the violins such that trace 0 is vertically aligned with trace 2 if the are related. I propose to resolve this with the Note that I would expect that when #1549 is implemented, that alignment would take into account matched-but-not-colinear axes, such that "room is left" for unaligned traces in non-colinear subplots. |
related: #78 |
Hmmm. #78 confuses me a bit, but I think my proposal is a way forward for some of those cases? |
I might be nice to combine @nicolaskruchten 's It would also be nice to find a solution that would allow us to plot stacked-grouped bar charts (cc #1835). From its This might be worth discussing during tomorrow's meeting. |
Wow that seems like a big chunk of work! Let’s discuss :)
…On Wed, Jan 16, 2019 at 18:23 Étienne Tétreault-Pinard < ***@***.***> wrote:
I might be nice to combine @nicolaskruchten
<https://github.com/nicolaskruchten> 's alignmentgroup proposal with an
attempt to augment trace-layout attributes (e.g. barmode and boxmode) to
something similar to scatter's stackgroup like we discussed when specing
out stacked area <#1217>.
It would also be nice to find a solution that would allow us to plot
stacked-grouped bar charts (cc #1835
<#1835>).
From its description
<https://github.com/plotly/plotly.js/blob/master/src/traces/scatter/attributes.js#L83>,
looks like stackgroup doesn't work across subplots, so these new group
attributes would have to be a little different. From #78
<#78>, we might even have to
add special logic for overlaying axes 😓
This might be worth discussing during tomorrow's meeting.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3402 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMbA7XT5tUj7F8OLWe2BfSPjAJR_4q3ks5vD7SCgaJpZM4ZxuRz>
.
|
Just so I understand, @etpinard you're thinking that we could model cross-subplot alignment as a kind of stacking and rolling it into |
|
To (attempt to) sum up @alexcjohnson's #3402 (comment) would be declared as [{
x: ['A', 'B', 'C', 'D'],
y: [1, 2, 3, 4],
alignmentgroup: 0
}, {
x: ['A', 'B', 'C', 'D'],
y: [2, 3, 1, 5],
alignmentgroup: 1
}, {
x: ['A', 'B', 'C', 'D'],
y: [1, 2, 3, 4],
yaxis: 'y2',
alignmentgroup: 0
}, {
x: ['A', 'B', 'C', 'D'],
y: [2, 3, 1, 5],
yaxis: 'y2',
alignmentgroup: 1
}] and as [{
x: ['A', 'B', 'C', 'D'],
y: [1, 2, 3, 4],
alignmentgroup: 0
}, {
x: ['A', 'B', 'C', 'D'],
y: [2, 3, 1, 5],
alignmentgroup: 1
}, {
x: ['A', 'B', 'C', 'D'],
y: [1, 2, 3, 4],
yaxis: 'y2',
alignmentgroup: 2
}, {
x: ['A', 'B', 'C', 'D'],
y: [2, 3, 1, 5],
yaxis: 'y2',
alignmentgroup: 3
}], {
// N.B. need to set this
// as the violinmode dflt is 'overlay'
violinmode: 'group'
} But something like [{
y: [1, 2, 1],
yaxis: 'y2'
}, {
y: [2, 1, 2]
}, {
y: [1, 3, 0]
}] which currently looks like: couldn't be declared using just [{
y: [1, 2, 1],
alignmentsupergroup: 'top'
yaxis: 'y2'
}, {
y: [2, 1, 2],
alignmentsupergroup: 'bottom',
alignmentgroup: 0
}, {
y: [1, 3, 0],
alignmentsupergroup: 'bottom',
alignmentgroup: 1
}] |
I don't think |
re the |
Actually of course we can, sorry, brainfart. I still don't think |
(just to clarify my comment on |
Hmm, upon further thought, looking at that last chart, given that I was in Secondly, I wonder if the "one trace above, two below" case isn't modelable by having them all have the same |
I feel like it would be just as easy - possibly even easier - to add the full functionality in one go, with the default values set to match current behavior. Then we don't need to carry around a special algorithm for the grandfathered case, and as a bonus we're done with this feature. Implementation can proceed by first adding a bunch of test cases of the edge cases we've identified in the current behavior (ensuring of course that we don't consider them bugs!) then adding the new behavior and ensuring the new (and existing) test cases all still pass.
If two traces (on the same position axis) have the same Still not so happy about the names... what about |
So for |
OK so just to sum up the verbal conversation we just had (assuming orientation is vertical):
So we need to crisp up the definitions of |
Note: we'll also need a way of doing |
Here are the photos we discussed over Slack. Note that the bottom-right quadrant was eventually considered not worth supporting (stacking on top of bars in another subplot) if we consider 2 bar traces with 1 datum x=1/y=1 here below the orange boxes have the SAME alignmentgroup/yaxis and DIFFERENT offsetgroup/stackgroup (so they always render like the top-left box of the original diagram) |
hehe, so awesome to see whiteboard-to-test-case! |
@nicolaskruchten what are the minimal requirements for this ticket? I'm thinking for
|
I’ll have to think about what it would mean to leave out stacking... for PX we don’t need bars to stack spanning each other and we don’t need mixes of groups and stacks but we do need aligned stacks. I’ll try to demo what I mean. |
After some thought, I think your proposal works for me for 1.45.0, and we don't need |
Split off of #3390 ...
the image below (see https://plot.ly/~nicolaskruchten/260) shows that each subplot "leaves room" for traces that are present only in other subplots, leading to undesirable horizontal offsets:
The text was updated successfully, but these errors were encountered: