-
-
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
Grouped bar charts do not work with multiple Y axes #78
Comments
Note: I used the above link just to show the issue; what I'm interested is to have this working in the JavaScript library. |
Thanks @iustin - yes, we should be able to support that. The rule (I think) should be: group bar traces that are on the same position axis, and on the same or overlaying the same size axis. |
+1 Right now I am just using overlayed charts with a high alpha on each bar so that I can see through the overlay. |
@dprice60 (or anyone else) could you upload an example of this workaround? |
@mbonaci Here is a simple one using the original example: https://plot.ly/~dprice60/0/grouped-bar-chart-with-multiple-axes/ That's all I have time to do right now, if you need me to do more I can try and put together something better later (like in a couple of days). The interface doesn't allow me to do everything that I normally have been doing but it let me get something up quick. If you click the code tab, I usually would replace the rgb(r,g,b) values with rgba(r,g,b,a). For the main color I've been using an alpha of .5 and for the stroke lines an alpha of 1. That helps make it more obvious that they are overlaying charts instead of stacked charts. Hope that helps. |
Thanks for that @dprice60, but that looks to me like the Which is exactly what happens when I remove the second, |
I don't have a way to do |
No, that's ok, I misunderstood your comment, or maybe was just hoping that you have a workaround :) |
A hack that can get the effect you want is to make dummy traces with one point each and zero value, in place of each trace on the other y axis. So for example, if you want the first trace on
Be warned though that once this issue is fixed, plots using this hack will break - this plot would then show up as a single group of 4 traces, two of which are invisible but still get space allotted to them. |
Thanks @alexcjohnson, that was really helpful.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi, I tried @mbonaci and @alexcjohnson suggestion and it works for vertical chart. I want to try to make it work with horizontal bar charts and replaced x with y and vise versa, but it does not work. Any thoughts on this? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is my workaround with 2 series and 2 categories. Adjusting opacity only made it look like stacked so I changed the width as well. For me, it really depends on the data to come up with the workaround though. I'd change those narrow bars to lines or some subtle marks if I feel it would represent the relationship between 2 series better. Having said, I still need to have the grouped bars with 2 axes in some cases. |
@real-np could you explain how you got the bars to appear side-by-side instead of overlayed directly on top of eachother? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
The code below would be a workaround if you really need grouped bar charts with multiple axes. Here trace2 stacks on trace 0, trace 3 stacks on trace 1. trace0 = go.Bar(x = ['a','b','c'], y=[10,20,30])
trace1 = go.Bar(x = ['a','b','c'], y=[0],showlegend=False,hoverinfo='none')
trace2 = go.Bar(x = ['a','b','c'], y=[0], yaxis='y2',showlegend=False,hoverinfo='none')
trace3 = go.Bar(x = ['a','b','c'], y=[30,35,60], yaxis='y2')
data = [trace0,trace1,trace2,trace3]#,trace2
layout = go.Layout(barmode='group',
legend=dict(x=0, y=1.1,orientation="h"),
yaxis=dict(title='2017 Increase(%)'),
yaxis2=dict(title = 'Transaction Count 2016(AUD)',
overlaying = 'y',
side='right'))
fig = go.Figure(data=data, layout=layout)
offline.iplot(fig) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR #3529 introduced (set to be released in See https://codepen.io/etpinard/pen/yZQYzq?editors=1010 for an example. |
Hi etpinard, is it intended that the yaxis and yaxis2 grids are not aligned? I thought {"anchor":"x"} was doing that. I also have unaligned grid axis with an horizontal bar chart I made (see below, sorry did not make it with codepen):
|
@ThibTrip please use https://community.plot.ly/c/plotly-js for questions of the likes. Thank you! |
@etpinard's demo using latest plotly.js seems to be working fine. Wondering if that workaround is enough to close this issue? |
@archmoj for that specific case it's working OK, but if you e.g. omit |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $10k-$15k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
@real-np Hi, I have tried and looked up for many methods to plot such figure, but I still can't overlay two grouped barchart. Can you explain how you do it? Many thanks. |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Hi,
it seems that having a graph with group bar charts and multiple Y axis doesn't work. I've created the trivial graph https://plot.ly/~iustin/4/grouped-bar-chart-with-multiple-axes/ and tested that switching Col3 between yaxis and yaxis2 also toggles between grouped and non-grouped.
Is this intended? Logically speaking, it makes sense to be able to do this, so I guess it's only a technical limitation.
The text was updated successfully, but these errors were encountered: