能否在matplotlib中绘制直方图,使其看起来倒置,即直方图的底部沿顶轴,并“悬挂”下来?或者,如果使用 orientation='horizontal' ,这样直方图的底部就位于右手轴上?
orientation='horizontal'
是,使用 invert_yaxis :
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()
输出: