Ask Your Question
1

Is there any way to integrate matplotlib plots in my latex document using sagetex?

asked 2015-01-14 16:37:06 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I have used this code to draw a picture using matplotlib.pyplot sagenb plots this nicely but i couldn't get this in my latex document when i use sagetex.

\begin{sagesilent} import matplotlib.pyplot as plt plt.plot([1,2,3,4],[1, 3, 2, 4]) plt.savefig('test.png') \end{sagesilent}

i get this error message:

** Error in Sage code on line 53 of sagetextest.tex! Traceback follows. Traceback (most recent call last): File "sagetextest.py", line 69, in <module> sagetex.plot(_sage_const_3 , plt.printfig('test.png'), format='notprovided', epsmagick=False) AttributeError: 'module' object has no attribute 'printfig'

** Running Sage on sagetextest.sage failed! Fix sagetextest.tex and try again.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-01-14 18:56:30 +0200

dazedANDconfused gravatar image

updated 2015-01-14 18:58:55 +0200

Yes, it's possible to integrate matplotlib plots in my latex document using sagetex. But first: there's no code here to see what is wrong. A message "Unknown environment "sagesilent" sounds like you haven't put \usepackage{sagetex} in the preamble (or maybe you haven't been able to successfully get latex and Sage to communicate. Also it sounds like you've used printfig when that command isn't available to you--and you should indent 4 spaces for code to show up nicely formatted in your question.

You can find a working example of sagetex with mathplotlib over on TeXStackExchange here: the answer by DJP has code you can copy/paste along with the working output that results.

edit flag offensive delete link more

Comments

thanks for the answer. understood from the example.

noufalasharaf gravatar imagenoufalasharaf ( 2015-01-15 13:21:58 +0200 )edit

If the answer solved your problem, feel free to click the check mark so that other visitors to the site know the question has a correct answer - thanks!

kcrisman gravatar imagekcrisman ( 2015-01-16 03:14:49 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-01-14 16:37:06 +0200

Seen: 699 times

Last updated: Jan 14 '15