Last active
September 16, 2019 20:23
-
-
Save pharpend/d57c002700d4834d406c705ebd30f3a1 to your computer and use it in GitHub Desktop.
Sage graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sage | |
# -*- mode: Python -*- | |
'''To run this, run the terminal command "sage graphs.sage". Or simply run the | |
command sage and type the lines of code into the prompt | |
To get help, from the sage prompt run help(plot), or see | |
http://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html | |
''' | |
# Simplest graph | |
p = plot(x**2, 0, 10) | |
# To just show | |
p.show() | |
# To save; pdf is lossless and allows infinite-precision zoom, so it is best choice. | |
# p.save("myfile.pdf") | |
# More complicated | |
q = plot([cos(x), sin(x), -x], -pi, pi, | |
color = ['green', 'purple', 'gray'], | |
linestyle=['-', '-', '--'], | |
thickness=3, | |
legend_label=['$\cos(x)$', '$\sin(x)$', '$-x$'], | |
ticks = ([-pi, -pi/2, 0, pi/2, pi], [-1, 0, 1]), | |
tick_formatter='latex') | |
q.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment