ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 May 2019 22:15:07 +0200How do I adjust the size of axes labels and figure titles in plots?https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/I've been experimenting around with the following code:
from sage.calculus.desolvers import desolve_odeint
y,dy = var('y,dy');
g = 9.8;
l = 1;
f = [dy,-g/l*cos(y)];
v = [y,dy];
t = srange(0,5,0.01);
ci = [0,0];
sol = desolve_odeint(f,ci,t,v,rtol=1e-15, atol=1e-10,h0=1e-4,hmax=1e-2,hmin=1e-6,mxstep=10000)
p = line(zip(t,sol[:,0]),title=r"$\frac{d^{2}\theta}{dt^2} = -\frac{g}{l} \cos{\theta}$",axes_labels=[r"$t$",r"$\theta$"]);
p2 = line(zip(t,sol[:,1]));
p2 += text(r"$\frac{d\theta}{dt}$",(-0.5,0),fontsize=27);
p2 += text(r"$t(s)$",(5,0.5),fontsize=20);
p.show()
which gives this plot:![image description](http://goo.gl/yiecUa)
As you can see the axes labels and title of the figure are insanely small (or at least in my opinion). I'd like the axes labels to be 20 pt and the figure title to be 30 pt. How do I do this? Tue, 12 May 2015 14:59:35 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/Answer by kcrisman for <p>I've been experimenting around with the following code:</p>
<pre><code>from sage.calculus.desolvers import desolve_odeint
y,dy = var('y,dy');
g = 9.8;
l = 1;
f = [dy,-g/l*cos(y)];
v = [y,dy];
t = srange(0,5,0.01);
ci = [0,0];
sol = desolve_odeint(f,ci,t,v,rtol=1e-15, atol=1e-10,h0=1e-4,hmax=1e-2,hmin=1e-6,mxstep=10000)
p = line(zip(t,sol[:,0]),title=r"$\frac{d^{2}\theta}{dt^2} = -\frac{g}{l} \cos{\theta}$",axes_labels=[r"$t$",r"$\theta$"]);
p2 = line(zip(t,sol[:,1]));
p2 += text(r"$\frac{d\theta}{dt}$",(-0.5,0),fontsize=27);
p2 += text(r"$t(s)$",(5,0.5),fontsize=20);
p.show()
</code></pre>
<p>which gives this plot:<img alt="image description" src="http://goo.gl/yiecUa"/></p>
<p>As you can see the axes labels and title of the figure are insanely small (or at least in my opinion). I'd like the axes labels to be 20 pt and the figure title to be 30 pt. How do I do this? </p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?answer=26808#post-id-26808You can do
p.fontsize(30)
to [change the font size for the labels and ticks](http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.Graphics.fontsize).
Unfortunately we don't seem to have the title font size set capability exposed from matplotlib, though surely this is possible too.Tue, 12 May 2015 16:03:17 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?answer=26808#post-id-26808Comment by Fusion809 for <p>You can do </p>
<pre><code>p.fontsize(30)
</code></pre>
<p>to <a href="http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.Graphics.fontsize">change the font size for the labels and ticks</a>.</p>
<p>Unfortunately we don't seem to have the title font size set capability exposed from matplotlib, though surely this is possible too.</p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26811#post-id-26811What about figure titles?Tue, 12 May 2015 18:07:31 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26811#post-id-26811Answer by eric_g for <p>I've been experimenting around with the following code:</p>
<pre><code>from sage.calculus.desolvers import desolve_odeint
y,dy = var('y,dy');
g = 9.8;
l = 1;
f = [dy,-g/l*cos(y)];
v = [y,dy];
t = srange(0,5,0.01);
ci = [0,0];
sol = desolve_odeint(f,ci,t,v,rtol=1e-15, atol=1e-10,h0=1e-4,hmax=1e-2,hmin=1e-6,mxstep=10000)
p = line(zip(t,sol[:,0]),title=r"$\frac{d^{2}\theta}{dt^2} = -\frac{g}{l} \cos{\theta}$",axes_labels=[r"$t$",r"$\theta$"]);
p2 = line(zip(t,sol[:,1]));
p2 += text(r"$\frac{d\theta}{dt}$",(-0.5,0),fontsize=27);
p2 += text(r"$t(s)$",(5,0.5),fontsize=20);
p.show()
</code></pre>
<p>which gives this plot:<img alt="image description" src="http://goo.gl/yiecUa"/></p>
<p>As you can see the axes labels and title of the figure are insanely small (or at least in my opinion). I'd like the axes labels to be 20 pt and the figure title to be 30 pt. How do I do this? </p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?answer=26825#post-id-26825Hi,
The issue of "insanely small" axes labels has been solved in [ticket #18004](http://trac.sagemath.org/ticket/18004) and integrated in Sage 6.7.beta2. So, if you do not want to wait for the next main Sage release (6.7, in a few weeks probably), you may consider upgrading to the latest Sage 6.7.beta (beta5 at the time of this writing).
Eric.Thu, 14 May 2015 10:27:11 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?answer=26825#post-id-26825Comment by kcrisman for <p>Hi,</p>
<p>The issue of "insanely small" axes labels has been solved in <a href="http://trac.sagemath.org/ticket/18004">ticket #18004</a> and integrated in Sage 6.7.beta2. So, if you do not want to wait for the next main Sage release (6.7, in a few weeks probably), you may consider upgrading to the latest Sage 6.7.beta (beta5 at the time of this writing).</p>
<p>Eric.</p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26827#post-id-26827Nice! See http://trac.sagemath.org/ticket/18421 for the title size.Thu, 14 May 2015 17:00:36 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26827#post-id-26827Comment by eric_g for <p>Hi,</p>
<p>The issue of "insanely small" axes labels has been solved in <a href="http://trac.sagemath.org/ticket/18004">ticket #18004</a> and integrated in Sage 6.7.beta2. So, if you do not want to wait for the next main Sage release (6.7, in a few weeks probably), you may consider upgrading to the latest Sage 6.7.beta (beta5 at the time of this writing).</p>
<p>Eric.</p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26915#post-id-26915Sage 6.7 is out, so you may use it to fix the size of the axes labels. Within Sage 6.7, there is indeed a new option for 2D graphics: `axes_labels_size`, which sets the relative size of axes labels with respect to tick marks labels. The default value is 1.6, which results in larger axes labels.Fri, 22 May 2015 16:28:54 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=26915#post-id-26915Comment by stockh0lm for <p>Hi,</p>
<p>The issue of "insanely small" axes labels has been solved in <a href="http://trac.sagemath.org/ticket/18004">ticket #18004</a> and integrated in Sage 6.7.beta2. So, if you do not want to wait for the next main Sage release (6.7, in a few weeks probably), you may consider upgrading to the latest Sage 6.7.beta (beta5 at the time of this writing).</p>
<p>Eric.</p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=46168#post-id-46168the ticket is still open? after four years, and priority "major"? I want to use this, too.Sun, 14 Apr 2019 23:31:00 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=46168#post-id-46168Comment by kcrisman for <p>Hi,</p>
<p>The issue of "insanely small" axes labels has been solved in <a href="http://trac.sagemath.org/ticket/18004">ticket #18004</a> and integrated in Sage 6.7.beta2. So, if you do not want to wait for the next main Sage release (6.7, in a few weeks probably), you may consider upgrading to the latest Sage 6.7.beta (beta5 at the time of this writing).</p>
<p>Eric.</p>
https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=46478#post-id-46478Unfortunately, "major" is basically the same as "default". Since open source projects tend to go with what "scratches the itch" of developers, it does depend on whether someone with know-how, time, *and* interest converges on a given ticket.Wed, 08 May 2019 22:15:07 +0200https://ask.sagemath.org/question/26807/how-do-i-adjust-the-size-of-axes-labels-and-figure-titles-in-plots/?comment=46478#post-id-46478