0

I can't quite figure out how to ask my question properly. I am trying to set custom x,y ticks on a log-log plot. Following the answer here I did,

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())

This results in an overlapping ticklabels on of the axis. Does anyone knows why is this happening?

output

Navdeep Rana
  • 111
  • 1
  • 7
  • Since I couldn't find the solution, after a lot of searches. I posted it. Thanks for marking it as duplicate and pointing to the original. – Navdeep Rana Sep 18 '17 at 10:30

1 Answers1

0

This is the relevant github issue : https://github.com/matplotlib/matplotlib/issues/8386

Quick Solution:

ax.yaxis.set_major_formatter
   (matplotlib.ticker.ScalarFormatter())
ax.yaxis.set_minor_formatter
   (matplotlib.ticker.NullFormatter())
Navdeep Rana
  • 111
  • 1
  • 7