gpt4 book ai didi

matplotlib - 你如何在 matplotlib 中绘制一个颠倒的直方图?

转载 作者:行者123 更新时间:2023-12-04 16:02:41 28 4
gpt4 key购买 nike

您能否在 matplotlib 中绘制直方图,使其看起来倒置,即直方图的底部沿顶轴并“悬垂”下来?或者,如果使用 orientation='horizontal' 绘图,所以直方图的底部在右手轴上?

最佳答案

是的,使用 invert_yaxis :

df = pd.DataFrame({'a':[1,2,3,1,2,2,2],
'b':[1,1,1,3,2,2,2]})
ax = df.plot.hist()
ax.invert_yaxis()

输出:

enter image description here

关于matplotlib - 你如何在 matplotlib 中绘制一个颠倒的直方图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50031664/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com