首页 > 解决方案 > Matplotlib 不显示所有带有条形图的刻度/标签?

问题描述

绘制具有许多点的线时,matplotlib 会自动隐藏一些 x 轴刻度/标签,以确保所有标签都适合。

如果我想绘制一个有很多点的条形聊天,是否有办法让 matplotlib 像使用线图一样考虑 x 轴?现在它正试图挤进所有的标签。

标签: pythonmatplotlib

解决方案


我建议指定 xtick 标签列表:

plt.xticks([80,150,300]) ### In this case these are numbers, change them to your values 

推荐阅读