【发布时间】:2020-10-10 15:59:04
【问题描述】:
我有一个瀑布图,我想分别设置每个条的颜色(第一个为蓝色,第二个、第三个和第四个为红色,第五个为绿色,第六个为蓝色)。图表中的所有相关条都在增加,而 plotly 只允许您设置增加、减少和总计三种颜色。 有什么方法可以做我想做的事吗?
import plotly.graph_objects as go
fig = go.Figure(go.Waterfall(
name = "20", orientation = "v",
measure = ["relative", "relative", "relative", "relative", "relative", "total"],
x = ["Buy", "Transaction Cost", "Remodeling Cost", "Ownership Cost", "Gain", "Sell"],
textposition = "outside",
text = ["$200", "$14", "$45", "$5", "$86", "$350"],
y = [200, 14, 45, 5, 86, 350],
connector = {"visible": False}
))
fig.show()
正如我所说,我希望栏的颜色是:
blue for the first one, red for the 2nd, 3rd, and 4th one, green for 5th one, and blue for 6th one
【问题讨论】: