0

All, I can create a nice little waterfall chart using the code below. However, I would like to be able to split the data to show contributions to that specific metric.

For example I would like to split the waterfall bars by Local and International. ie. the Sales would have both Local and International adding up to the total. Can this be done.

import plotly.graph_objects as go

fig = go.Figure(go.Waterfall(
    name = "20", orientation = "v",
    measure = ["relative", "relative", "total", "relative", "relative", "total"],
    x = ["Sales", "Consulting", "Net revenue", "Purchases", "Other expenses", "Profit before tax"],
    textposition = "outside",
    text = ["+60", "+80", "", "-40", "-20", "Total"],
    y = [60, 80, 0, -40, -20, 0],
    connector = {"line":{"color":"rgb(63, 63, 63)"}},
))

fig.update_layout(
        title = "Profit and loss statement 2018",
        showlegend = True
)

fig.show()

Aksel Etingu
  • 195
  • 2
  • 15
  • 1
    This would be handled with `layout.waterfallmode` but at the moment we only support side-by-side and overlay, not stacking. – nicolaskruchten Aug 02 '19 at 12:50
  • that is a pity. I will try to find alternative ways (besides excel:) – Aksel Etingu Aug 02 '19 at 13:50
  • It’s a challenging thing to implement... unclear how to handle cases where parts of the same stack have different signs. I’d love to see how other tools handle it! – nicolaskruchten Aug 02 '19 at 13:59
  • It looks like it is possible on R using ggplot2. [Here is an example](https://stackoverflow.com/questions/48259930/how-to-create-a-stacked-waterfall-chart-in-r) – Aksel Etingu Aug 06 '19 at 10:17

0 Answers0