如何在绘图表达箱线图中按月份更改/排序条形位置作为颜色?
朋友们 我试图将我的数据绘制成箱线图。
这是我的数据
这是箱线图
import plotly.express as px
fig = px.box(df_hb, x="QUESTION DETAIL", y="ANSWER", color="MONTH", title="Buy Price", points="outliers",
labels={"QUESTION DETAIL" : "Product", "ANSWER" : "Buy Price"})
fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
fig.update_layout(paper_bgcolor='white',
plot_bgcolor='white',
autotypenumbers='convert types',
legend_traceorder="normal"
)
fig.show()
我的问题是,我想对位置进行排序条形按月份作为颜色。 我想将“FEBRUARY”颜色移到“MARCH”颜色之前
friends
Im trying to plot my data to a boxplot.
this is my data
this is the boxplot graph
import plotly.express as px
fig = px.box(df_hb, x="QUESTION DETAIL", y="ANSWER", color="MONTH", title="Buy Price", points="outliers",
labels={"QUESTION DETAIL" : "Product", "ANSWER" : "Buy Price"})
fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
fig.update_layout(paper_bgcolor='white',
plot_bgcolor='white',
autotypenumbers='convert types',
legend_traceorder="normal"
)
fig.show()
my problem is, i want to sort the position of bar by the month as a color.
i want to move "FEBRUARY" color before "MARCH" color
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看文档,您将看到有一个名为
category_orders
的属性。您可以这样添加订单:If you look at the documentation, you will see there is an attribute called
category_orders
. You can add the order like that: