1

With matplotlib when a log scale is specified for an axis, the default method of labeling that axis is with numbers that are 10 to a power eg. 10^6. Is there an easy way to change all of these labels to for example: 1, 5, 10, 20?

aloha
  • 4,554
  • 6
  • 32
  • 40

1 Answers1

3

Found in this thread

import matplotlib.pyplot as pl
from matplotlib.ticker import ScalarFormatter

fig = pl.figure()
ax = fig.add_subplot(111)

ax.set_xscale('log')
ax.set_xticks([1,2,5,10])
ax.get_xaxis().set_major_formatter(ScalarFormatter())
ax.set_xlim([1., 10.])

enter image description here

Community
  • 1
  • 1
Daniel Lenz
  • 3,334
  • 17
  • 36