sensible tick labels for log scale (rephrased)

Sorry for the lack of clarity in my last shot at this problem. What I want to be able to do is change a plot's axis to the log scale, then have some reasonable (i.e. evenly-spaced) tick labels generated automatically. I have tried to do this manually, but end up with the following:

http://cl.ly/3h1T2i0a0T3X0K2b3W11

After Paul's answer to the original message, I have tried messing with the major_locator:

ml = MultipleLocator(0.2)
ax.xaxis.set_major_locator(ml)

with different values for the MultipleLocator. Though the ticks do change, I only am able to see labels such as 10^0, 10^1, etc. -- I need better labels than that, such as [0, 0.3, 0.5, 1, 2, 4, 7] -- these are good values, because they are unlikely to overlap on the log scale. It will be a pain, however, to do this manually for every plot, so I am looking for a way to automate this somehow. I was hoping (and still hope) that Matplotlib is able to choose reasonable ticks on the log scale that do not overlap, but are more informative than just powers of 10.

Hope that is clearer,
cf

Chris Fonnesbeck, on 2011-01-13 14:07, wrote:

I was hoping (and still hope) that Matplotlib is able to choose
reasonable ticks on the log scale that do not overlap, but are
more informative than just powers of 10.

Chris,

Sorry, I'm no expert with the locators, I rarely find myself
needing to mess with them. The cleaner way to get something other
than decades is to specify basex and basey. To do this for a plot
already created, you'll need to set the base of the LogLocator
and LogFormatter of your minor and major axes, like:

  fmat = plt.gca().xaxis.get_major_formatter()
  fmat.base(2)
  loc = plt.gca().xaxis.get_major_locator()
  loc.base(2)

I'm afraid I'm quite out of my element with these guys, maybe
someone else chimes in with another approach. Do post again to
clarify what you want.

Note that by default, the minor_formatter is set to be a
NullFormatter, thus no labels will be placed at the minor tick
locations. That would be a reasonable way to proceed - set the
major ticks to be non-overlapping, and put the minor ones
everywhere else.

You've probably already found it, but just in case:
http://matplotlib.sourceforge.net/api/ticker_api.html

ยทยทยท

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7