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.Thu, 14 Aug 2014 22:44:23 +0200axis_thickness ?https://ask.sagemath.org/question/23762/axis_thickness/I would like to like to increase the thickness of my axes on my plots. How might I do this?
Background: I am a teacher who uses sage to make my own graph paper. The axes look good on paper (although I'd like to have arrows on them), but when I project the pdf onto my white board (to draw on) the axes don't look much thicker than the gridlines (I'm using greyed instead of dashed gridlines). Here's my code:
k = 8
p = plot(k, (x, -k, k),
thickness = 0,
aspect_ratio = 1,
gridlines = True,
axes_labels=['$x$','$y$'],
ticks=[[-k..k],[-k..k]],
tick_formatter = [['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$'], ['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$']],
gridlinesstyle = dict(color = "gray", linestyle = "-")
)
p += plot(0, (x, -k, k), thickness = 0) #to establish graph width
p += plot(-k, (x, -k, k), thickness = 0) #to establish graph height
show(p)
p.save('graph8l.pdf')Wed, 13 Aug 2014 20:34:15 +0200https://ask.sagemath.org/question/23762/axis_thickness/Comment by kcrisman for <p>I would like to like to increase the thickness of my axes on my plots. How might I do this?</p>
<p>Background: I am a teacher who uses sage to make my own graph paper. The axes look good on paper (although I'd like to have arrows on them), but when I project the pdf onto my white board (to draw on) the axes don't look much thicker than the gridlines (I'm using greyed instead of dashed gridlines). Here's my code:</p>
<pre><code>k = 8
p = plot(k, (x, -k, k),
thickness = 0,
aspect_ratio = 1,
gridlines = True,
axes_labels=['$x$','$y$'],
ticks=[[-k..k],[-k..k]],
tick_formatter = [['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$'], ['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$']],
gridlinesstyle = dict(color = "gray", linestyle = "-")
)
p += plot(0, (x, -k, k), thickness = 0) #to establish graph width
p += plot(-k, (x, -k, k), thickness = 0) #to establish graph height
show(p)
p.save('graph8l.pdf')
</code></pre>
https://ask.sagemath.org/question/23762/axis_thickness/?comment=23768#post-id-23768Nice idea!Thu, 14 Aug 2014 06:08:48 +0200https://ask.sagemath.org/question/23762/axis_thickness/?comment=23768#post-id-23768Answer by dazedANDconfused for <p>I would like to like to increase the thickness of my axes on my plots. How might I do this?</p>
<p>Background: I am a teacher who uses sage to make my own graph paper. The axes look good on paper (although I'd like to have arrows on them), but when I project the pdf onto my white board (to draw on) the axes don't look much thicker than the gridlines (I'm using greyed instead of dashed gridlines). Here's my code:</p>
<pre><code>k = 8
p = plot(k, (x, -k, k),
thickness = 0,
aspect_ratio = 1,
gridlines = True,
axes_labels=['$x$','$y$'],
ticks=[[-k..k],[-k..k]],
tick_formatter = [['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$'], ['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$']],
gridlinesstyle = dict(color = "gray", linestyle = "-")
)
p += plot(0, (x, -k, k), thickness = 0) #to establish graph width
p += plot(-k, (x, -k, k), thickness = 0) #to establish graph height
show(p)
p.save('graph8l.pdf')
</code></pre>
https://ask.sagemath.org/question/23762/axis_thickness/?answer=23764#post-id-23764The basic answer to your question is [here](http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html): use the p.axes_width() command to change the axes width. Go to a [Sage cell server](https://sagecell.sagemath.org/) and copy/paste your code with the extra line to thicken the axes:
k = 8
p = plot(k, (x, -k, k),
thickness = 0,
aspect_ratio = 1,
gridlines = True,
axes_labels=['$x$','$y$'],
ticks=[[-k..k],[-k..k]],
tick_formatter = [['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$'], ['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$']],
gridlinesstyle = dict(color = "gray", linestyle = "-")
)
p += plot(0, (x, -k, k), thickness = 0) #to establish graph width
p += plot(-k, (x, -k, k), thickness = 0) #to establish graph height
p.axes_width(5)
show(p)
p.save('graph8l.pdf')
and the result will be thick axes for your screen output as well as the PDF output.
Given that latex is integrated with Sage, I think you could have much better looking graph paper working in LaTeX, such as is mentioned [here](http://tex.stackexchange.com/questions/40780/tikz-pgf-draw-integral-test-plot). The tkz-fct package, for example can give good results.Wed, 13 Aug 2014 23:12:32 +0200https://ask.sagemath.org/question/23762/axis_thickness/?answer=23764#post-id-23764Comment by mathochist for <p>The basic answer to your question is <a href="http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html">here</a>: use the p.axes_width() command to change the axes width. Go to a <a href="https://sagecell.sagemath.org/">Sage cell server</a> and copy/paste your code with the extra line to thicken the axes:</p>
<pre><code>k = 8
p = plot(k, (x, -k, k),
thickness = 0,
aspect_ratio = 1,
gridlines = True,
axes_labels=['$x$','$y$'],
ticks=[[-k..k],[-k..k]],
tick_formatter = [['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$'], ['$-8$', '', '$-6$', '', '$-4$', '', '$-2$', '', '', '', '$2$', '', '$4$', '', '$6$', '', '$8$']],
gridlinesstyle = dict(color = "gray", linestyle = "-")
)
p += plot(0, (x, -k, k), thickness = 0) #to establish graph width
p += plot(-k, (x, -k, k), thickness = 0) #to establish graph height
p.axes_width(5)
show(p)
p.save('graph8l.pdf')
</code></pre>
<p>and the result will be thick axes for your screen output as well as the PDF output. </p>
<p>Given that latex is integrated with Sage, I think you could have much better looking graph paper working in LaTeX, such as is mentioned <a href="http://tex.stackexchange.com/questions/40780/tikz-pgf-draw-integral-test-plot">here</a>. The tkz-fct package, for example can give good results.</p>
https://ask.sagemath.org/question/23762/axis_thickness/?comment=23794#post-id-23794Thank's a ton. I looked all through the 2D Plotting page and didn't think to look at Graphics objects. I should probably read through the documentation completely some time.
I aim to continue my LaTeX/Sage integration as well. I haven't had a ton of success on my home or work setup. Maybe that tkz-fct package will help.
Thanks again.
(Edit: spelling)Thu, 14 Aug 2014 22:44:23 +0200https://ask.sagemath.org/question/23762/axis_thickness/?comment=23794#post-id-23794