Default format of numbers on logscale and arbitrary tick marks

I am a new user to python and I discovered something rather annoying and
wondered if a better default solution could be determined. I am not sure if
this has already been discussed before but a quick look on google and the
Nabble forum didn't yield any obvious clues so I decided to create a new

My original problem was that I was unable to specify labelled arbitrary
ticks in logscale plots. For example:

import matplotlib.pyplot as mpl

mpl.xticks([1.0, 2.0, 2.3, 2.35])

will correctly output the changed ticks and label them. However:

mpl.xticks([1.0, 2.0, 2.3, 2.35])

will only display the minor ticks and fail to label any of them other than
the the value 1.0. This is also true for the semilogx() function. I think
this was because the default format is given as 10^n, where n is an integer
and there are no integers that can describe the 2.0, 2.3 and 2.35 values
above. To solve the problem I used:

import matplotlib.pyplot as mpl
from matplotlib.ticker import FuncFormatter

def label_form(x, pos):
    return str(float(x))

mpl.xticks([1.0, 2.0, 2.3, 2.35])

which wasted a fair couple of hours of my life! Imho I would prefer it if
the default format was in scientific exponential notation: 2.3e10 or
standard form: 2.3x10^10 for logscale plots. A selection criteria could be
applied for the case of floats = 1.0, 10.0, 100.0 such that it could print
in the 10^n format. In any case, I think it is more important to allow
labels to be displayed in an uglier format when requested rather than
ignored, without informing the user, for the sake of aesthetics. I also
noticed that for linear plots the format of the numbers is to print a float
and then put the exponential part separately beside the axis. For example:

mpl.xticks([1.0, 2.0, 2.3, 2.35])

Although this is looks neat, it would have looked odd to have it in this
format for publication. I would prefer to divide my data by 1.0e10 and put
in the ylabel "Data ($10^10$ units)" or just have each number in scientific
exponential format or standard form. As an example of this in practise, it
is sometimes convenient to publish temperature plots in astrophysics in T_9,
which is the temperature in 10^9 K.

What do you think? If this has already been discussed in detail, I
apologise for bringing it up again. In which case, I would appreciate a
link to the thread/web page.


View this message in context:
Sent from the matplotlib - users mailing list archive at