question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Stack" vs "Relative" barmode

See original GitHub issue

Hi There,

First off, thanks for making and open-sourcing this library; it is proving very useful.

I wanted to propose a tiny code change to 2 lines in the instantiation of the plotly renderers in PlotlyRenderes.jsx. Specifically, I’m wondering if the layout options passed into the two stacked bar charts could specify { barmode: 'relative' } instead of { barmode: 'stack' }.

There may be reasons not to do it, which I’m not aware of, because I’m far from intimately familiar with plotly.js. However, the reason pro doing it is that currently, with { barmode: 'stack' }, if there are any negative values in the data, their bars end up overlapping and covering up other bars instead of sticking out on the negative side of the chart. In other words, as far as I can tell, when there are negative values, ‘stack’ mode results in a bug while ‘relative’ mode does what you’d expect. And I don’t think there’s a case where the opposite is true.

The only discussion I’ve found about this so far is this forum post in which someone points out this issue and Etienne addresses by creating the new { barmode: 'relative' }. However, no explanation is given as to why a new mode was needed instead of modifying the ‘stack’ mode.

Thanks for your consideration.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, May 8, 2018

Also, thanks to your issue, we finally resolved https://github.com/plotly/documentation/issues/926 such that barmode now appears here alongside all the other layout attributes https://plot.ly/javascript/reference/#layout-barmode so thanks for the nudge 😃

0reactions
meetamitcommented, May 8, 2018

@nicolaskruchten Super! Thanks – both for making and releasing the change, and for doing all the prerequisite sifting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bar charts in Python - Plotly
With "relative" barmode, the bars are stacked on top of one another, with negative values below the axis, positive values above. In [31]:....
Read more >
Plotly px.bar not stacking with barmode='stack' - Stack Overflow
effectively you want to plot all the bars against same x value. Have done this by setting it as a constant in data...
Read more >
How to plot a grouped stacked bar chart in plotly - Medium
Unfortunately, barmode only takes either stack or group but not both as an argument. It seems like they are currently working on this...
Read more >
Stacked Bar Charts with Plotly Express - Towards Data Science
100% Stacked Bars place the percentage of each subcategory after or ... for overlapped bar charts, or barmode = 'group' to place bars...
Read more >
Stacked bar chart — Matplotlib 3.6.2 documentation
This is an example of creating a stacked bar plot with error bars using bar . Note the parameters yerr used for error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found