你可以循环你的x轴刻度并增加每个其他刻度的垫,使它们低于其他刻度.一个最小的例子是:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1,2,3,4,5])
ax.set_xticks([1,2,3,4,5])
ax.set_xticklabels(["A","B","C","D","E",])
# [1::2] means start from the second element in the list and get every other element
for tick in ax.xaxis.get_major_ticks()[1::2]:
tick.set_pad(15)
plt.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1305 次 |
| 最近记录: |