如何在plotly dash中用category_orders函数按字母顺序排序传说
我正在使用Plotly Dash创建散点图。我在最终数字中获得的传奇是随机放置的。我想使用category_orders
函数以字母顺序从A到Z对标签进行排序
fig = px.box(
df,
x=selected_x,
y=selected_y,
points='all',
hover_data=hover_data,
color=colour_by,
width=800,
height=600,
labels={
selected_y: "{} {}".format(selected_y_gene, selected_y),
selected_x: "{} {}".format(selected_x_gene, selected_x),
},
I am using Plotly dash for creating a scatter plot. The legends I am getting in the final figure are randomly placed. I want to sort labels alphabetically from A to Z with category_orders
function
fig = px.box(
df,
x=selected_x,
y=selected_y,
points='all',
hover_data=hover_data,
color=colour_by,
width=800,
height=600,
labels={
selected_y: "{} {}".format(selected_y_gene, selected_y),
selected_x: "{} {}".format(selected_x_gene, selected_x),
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有很多标签,那么一个简单的选择是使用
categoryorder
例如,使用 layout.xaxis 。Example using the iris dataset:
If you wish to use
category_orders
in plotly.express.box:If there are many labels, a simple alternative would be to use
categoryorder
e.g for x-axis using Layout.xaxis.Example using the iris dataset:
If you wish to use
category_orders
in plotly.express.box: