问题
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()
来源:https://stackoverflow.com/questions/57310163/plotly-waterfall-chart-stacked-in-python