# How to increase numer of internal decimal places on axis?

When ploting graphs with a small y-range it can happen that the whole y-axis shows the same number at the ticks. see attached pic.

how can i increase the number of decimal places?

the plot command i use is

plot([f, f_lower, f_upper],(x,0.2,0.99), color=['blue', 'red', 'green'], legend_label=['Wert ohne Fehler',  'untere Fehlerschranke', 'obere Fehlerschranke'], axes_labels=['Tiefe in Z-Richtung in m','$\\frac{4 \\, \\pi {{\\varphi_{ges}}}}{U}$'], figsize=8, title='all values have errors. but this is without seawater, just sediment', title_pos=(0.5,1.1)).save('JustSediment.png')


but i suppose i will just need to add a clever option (which i was unable to locate in this forum or the documentation).

C:\fakepath\JustSediment.png

edit retag close merge delete

Sort by » oldest newest most voted

Use custom ticks as mentioned in the documentation or question 7855 on ask. In your situation, something like this might work

sage: from matplotlib import ticker
sage: TT = ticker.FormatStrFormatter('%.7e')
sage: point2d([(0, 7.9123432e-12), (1, 7.9123471e-12), (2, 7.9123457e-12)], tick_formatter=[None,TT])


Though it is not very readable. I would advice you to translate the y-axis so that you actually see the difference on the first digit (in my case I would translate by 7.91234e-12).

more

would you please explain what you mean by "translate the y-axis"? how do you translate an axis?

I mean: change the y coordinate of your data by some amount so that the difference between the numbers is visible on the digits. For example with

sage: l = [1.23456721, 1.23456783, 1.23456752, 1.23456731, 1.23456711]


it is hard to tell quickly which one is bigger which one is smaller. On the other hand here it becomes evident

sage: [x - 1.234567 for x in l]
[2.10000000055999e-7,
8.30000000062725e-7,
5.19999999948340e-7,
3.10000000114385e-7,
1.09999999997612e-7]