Ask Your Question

How to increase numer of internal decimal places on axis?

asked 2019-03-16 11:32:49 -0500

stockh0lm gravatar image

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).


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-03-16 14:45:04 -0500

vdelecroix gravatar image

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).

edit flag offensive delete link more


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

stockh0lm gravatar imagestockh0lm ( 2019-03-16 17:50:11 -0500 )edit

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]
vdelecroix gravatar imagevdelecroix ( 2019-03-17 06:02:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-03-16 11:32:49 -0500

Seen: 29 times

Last updated: Mar 16