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 post.
My original problem was that I was unable to specify labelled arbitrary ticks in logscale plots. For example: import matplotlib.pyplot as mpl mpl.plot([1,2,3],[4,5,6]) mpl.xticks([1.0, 2.0, 2.3, 2.35]) mpl.show() will correctly output the changed ticks and label them. However: mpl.loglog([1,2,3],[4,5,6]) mpl.xticks([1.0, 2.0, 2.3, 2.35]) mpl.show() 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.loglog([1,2,3],[4,5,6]) mpl.xticks([1.0, 2.0, 2.3, 2.35]) mpl.gca().xaxis.set_major_formatter(FuncFormatter(label_form)) mpl.show() 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.plot([1,2,3],[4e10,5e10,6e10]) mpl.xticks([1.0, 2.0, 2.3, 2.35]) mpl.show() 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: http://old.nabble.com/Default-format-of-numbers-on-logscale-and-arbitrary-tick-marks-tp27772714p27772714.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users