First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Shashank told you how to do it in matplotlib (which comes with Sage) - matplotlib allows you a lot of control over your plots, but as you can see, it involves a fair bit of boilerplate compared to Sage's plotting.

If you want to add a formula to a Sage plot, then you can just use latex inside dollar signs, like you would in a .tex document:

text(r"Here's a formula $\frac{\sqrt{3}}{2}$ and some text",(1,2))

Here the r" is necessary due to all the slashes in the string–if you don't include the r then you'll have to escape each of the slashes (check out the python String documentation for more info on that).

click to hide/show revision 2
No.2 Revision

Shashank told you how to do it in matplotlib (which comes with Sage) - matplotlib allows you a lot of control over your plots, plots (I often use it for this reason), but as you can see, it involves a fair bit of boilerplate compared to Sage's plotting.

If you want to add a formula to a Sage plot, then you can just use latex inside dollar signs, like you would in a .tex document:

text(r"Here's a formula $\frac{\sqrt{3}}{2}$ and some text",(1,2))

Here the r" is necessary due to all the slashes in the string–if you don't include the r then you'll have to escape each of the slashes (check out the python String documentation for more info on that).