在 matplotlib
中,当我在一个轴上使用 log
刻度时,该轴可能会没有主要刻度,< strong>只有轻微的。所以这意味着整个轴没有标签显示。
我如何指定小刻度也需要标签?
我试过:
plt.setp(ax.get_xticklabels(minor=True), visible=True)
...但它并没有成功。
最佳答案
可以在相应的轴上使用set_minor_tickformatter
:
from matplotlib import pyplot as plt
from matplotlib.ticker import FormatStrFormatter
axes = plt.subplot(111)
axes.loglog([3,4,7], [2,3,4])
axes.xaxis.set_minor_formatter(FormatStrFormatter("%.2f"))
plt.xlim(1.8, 9.2)
plt.show()
关于python - Matplotlib:还显示小刻度的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17165435/