Matplotlib在log-log图上重叠tickslabels

时间:2017-09-18 04:48:32

标签: python matplotlib anaconda

我无法弄清楚如何正确地提出问题。 我试图在对数日志图上设置自定义x,y刻度。 根据我的回答here

fig1, ax1 = plt.subplots()
ax1.plot([10, 100, 1000], [1,2,3])
ax1.set_xscale('log')
ax1.set_yscale('log')
ax1.set_xticks([20, 200, 500])
ax1.set_yticks([1, 2,3])
ax1.get_xaxis().set_major_formatter
    (matplotlib.ticker.ScalarFormatter())
ax1.get_yaxis().set_major_formatter
    (matplotlib.ticker.ScalarFormatter())

这会导致轴上的重叠勾选标签。 有谁知道为什么会这样?

output

1 个答案:

答案 0 :(得分:0)

这是相关的github问题: https://github.com/matplotlib/matplotlib/issues/8386

快速解决方案:

ax.yaxis.set_major_formatter
   (matplotlib.ticker.ScalarFormatter())
ax.yaxis.set_minor_formatter
   (matplotlib.ticker.NullFormatter())