如何在Plotly Python中解开堆放的bargraph?
我正在使用PX栏图,在我的数据框架中,有重复的行将分配为X到bar绘图。 默认情况下,条形图将它们堆叠在一起,更改Barmode无济于事。 我想如下屏幕上的屏幕上分开绘制它们。 Excel会做到的方式。 先感谢您。
import plotly.express as px
abc=np.random.randint(1,30, 15)
df=pd.DataFrame(abc, columns=['v1'])
df['v2']=list('abc'*5)
fig = px.bar(df, x='v2',y='v1')
fig
I'm using px bar plot and in my dataframe there are repeating rows which will be assigned as x to bar plot.
By default bar plots stacks them, and changing barmode doesn't help.
I want to draw them seperatly as shown in screen below. The way excel would do it.
Thank you in advance.
import plotly.express as px
abc=np.random.randint(1,30, 15)
df=pd.DataFrame(abc, columns=['v1'])
df['v2']=list('abc'*5)
fig = px.bar(df, x='v2',y='v1')
fig
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,我认为最好将X轴指定为数据框架的索引,并使用列数据更新轴标签。
In such a case, I think it would be better to specify the x-axis as the index of the data frame and update the axis labels with the column data.