# 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')

edit retag close merge delete

Sort by » oldest newest most voted

The basic answer to your question is here: use the p.axes_width() command to change the axes width. Go to a Sage cell server 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. The tkz-fct package, for example can give good results.

more

Thank'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)