ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 15 Jan 2015 20:14:49 -0600Is there any way to integrate matplotlib plots in my latex document using sagetex?http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/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.
Wed, 14 Jan 2015 09:37:06 -0600http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/Answer by dazedANDconfused for <p>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.</p>
<p>\begin{sagesilent}
import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[1, 3, 2, 4])
plt.savefig('test.png')
\end{sagesilent}</p>
<p>i get this error message:</p>
<p><em>*</em>* 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'</p>
<p><em>*</em>* Running Sage on sagetextest.sage failed! Fix sagetextest.tex and try again.</p>
http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?answer=25522#post-id-25522Yes, 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](http://tex.stackexchange.com/questions/159093/contour-plot-of-arbitrary-r3-function-without-gnuplot/159223#159223): the answer by DJP has code you can copy/paste along with the working output that results.Wed, 14 Jan 2015 11:56:30 -0600http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?answer=25522#post-id-25522Comment by kcrisman for <p>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.</p>
<p>You can find a working example of sagetex with mathplotlib over on TeXStackExchange <a href="http://tex.stackexchange.com/questions/159093/contour-plot-of-arbitrary-r3-function-without-gnuplot/159223#159223">here</a>: the answer by DJP has code you can copy/paste along with the working output that results.</p>
http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?comment=25538#post-id-25538If 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!Thu, 15 Jan 2015 20:14:49 -0600http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?comment=25538#post-id-25538Comment by noufalasharaf for <p>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.</p>
<p>You can find a working example of sagetex with mathplotlib over on TeXStackExchange <a href="http://tex.stackexchange.com/questions/159093/contour-plot-of-arbitrary-r3-function-without-gnuplot/159223#159223">here</a>: the answer by DJP has code you can copy/paste along with the working output that results.</p>
http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?comment=25528#post-id-25528thanks for the answer. understood from the example.Thu, 15 Jan 2015 06:21:58 -0600http://ask.sagemath.org/question/25521/is-there-any-way-to-integrate-matplotlib-plots-in-my-latex-document-using-sagetex/?comment=25528#post-id-25528