ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 17 Mar 2019 06:02:07 -0500How to increase numer of internal decimal places on axis?http://ask.sagemath.org/question/45794/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](/upfiles/15527538172284579.png)
Sat, 16 Mar 2019 11:32:49 -0500http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/Answer by vdelecroix for <p>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. </p>
<p>how can i increase the number of decimal places?</p>
<p>the plot command i use is</p>
<pre><code>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')
</code></pre>
<p>but i suppose i will just need to add a clever option (which i was unable to locate in this forum or the documentation).</p>
<p><a href="/upfiles/15527538172284579.png">C:\fakepath\JustSediment.png</a></p>
http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?answer=45797#post-id-45797Use custom ticks as mentioned in [the documentation](http://doc.sagemath.org/html/en/reference/plotting/sage/plot/graphics.html) or [question 7855 on ask](https://ask.sagemath.org/question/7855/controlling-tick-marks-in-plots/). 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).Sat, 16 Mar 2019 14:45:04 -0500http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?answer=45797#post-id-45797Comment by vdelecroix for <p>Use custom ticks as mentioned in <a href="http://doc.sagemath.org/html/en/reference/plotting/sage/plot/graphics.html">the documentation</a> or <a href="https://ask.sagemath.org/question/7855/controlling-tick-marks-in-plots/">question 7855 on ask</a>. In your situation, something like this might work</p>
<pre><code>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])
</code></pre>
<p>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).</p>
http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?comment=45802#post-id-45802I 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]Sun, 17 Mar 2019 06:02:07 -0500http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?comment=45802#post-id-45802Comment by stockh0lm for <p>Use custom ticks as mentioned in <a href="http://doc.sagemath.org/html/en/reference/plotting/sage/plot/graphics.html">the documentation</a> or <a href="https://ask.sagemath.org/question/7855/controlling-tick-marks-in-plots/">question 7855 on ask</a>. In your situation, something like this might work</p>
<pre><code>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])
</code></pre>
<p>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).</p>
http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?comment=45798#post-id-45798would you please explain what you mean by "translate the y-axis"? how do you translate an axis?Sat, 16 Mar 2019 17:50:11 -0500http://ask.sagemath.org/question/45794/how-to-increase-numer-of-internal-decimal-places-on-axis/?comment=45798#post-id-45798