首页 > 解决方案 > Python matplotlib:旋转条形图的 x 轴标签

问题描述

刚开始编码,我还没有完全理解绘图。我正在创建一个帕累托图,我的条形标签很长。我从另一个线程复制了情节代码。如何旋转标签(45 或 90 度)

编码:

fig, ax = plt.subplots()
ax.bar(counts_clean_cutoff['error'], counts_clean_cutoff["counts"], color="C0")
ax2 = ax.twinx()
ax2.plot(counts_clean_cutoff['error'], counts_clean_cutoff["cumpercentage"], color="C1", marker="D", ms=7)
ax2.yaxis.set_major_formatter(PercentFormatter())

ax.tick_params(axis="y", colors="C0")
ax2.tick_params(axis="y", colors="C1")
plt.show()

谢谢!

标签: pythonmatplotlibbar-chartpareto-chart

解决方案


推荐阅读