【发布时间】:2021-12-18 16:29:15
【问题描述】:
这是我的代码:
fig = px.bar(
data_frame=dftotal,
x="YEAR",
y="OPINION",
title="Score des opinions par années",
color="OPINION",
width=1300,
height=700,
template='plotly_dark',
color_discrete_map={5: "green",4: "lightgreen",3: "yellow",2:"orange", 1: "red", "inconnu": "grey"}
)
fig.update_layout(title_x=0.5)
fig.show()
它给出了这个结果:
但我想在 2014 年的每一年中实现如下所示的结果。我认为,通过将每个值获得的“总分”相加。
我还想更改图例的标签名称。类似于:“非常糟糕”而不是“OPINION=1”。
【问题讨论】:
标签: plotly bar-chart plotly-python