ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 20 Sep 2013 11:18:11 +0200Graph theory exporting problemshttps://ask.sagemath.org/question/10549/graph-theory-exporting-problems/I type in the following SAGE code and get the graph on the screen that I would expect to get.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True)
When I try to export this to a file with the following code I get an "AssertionError" message.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True).save('graph.pdf')
How can I fix this so that I can output this graph as a pdf file. I love how easy I can make nice looking graphs in SAGE, but it is useless if I can't export them to use in Latex.
Thu, 19 Sep 2013 20:20:10 +0200https://ask.sagemath.org/question/10549/graph-theory-exporting-problems/Answer by John Palmieri for <p>I type in the following SAGE code and get the graph on the screen that I would expect to get.</p>
<p>g = Graph({0,[1,2,2]}); g</p>
<p>g.plot(graph_border = True)</p>
<p>When I try to export this to a file with the following code I get an "AssertionError" message.</p>
<p>g = Graph({0,[1,2,2]}); g</p>
<p>g.plot(graph_border = True).save('graph.pdf')</p>
<p>How can I fix this so that I can output this graph as a pdf file. I love how easy I can make nice looking graphs in SAGE, but it is useless if I can't export them to use in Latex.</p>
https://ask.sagemath.org/question/10549/graph-theory-exporting-problems/?answer=15473#post-id-15473Save it as a png file instead of a PDF file. What *should* work is
g.plot(graph_border = True).save('graph.png')
Then your LaTeX file should look like
\documentclass{article}
\usepackage{graphicx}
\begin{document}
Hello.
\includegraphics{graph.png}
Goodbye.
\end{document}
For this particular graph, I get a nicer picture doing `g.plot(graph_border = True)` than doing `g.plot(graph_border = True).save('graph.png')`, so I would actually do the first command to view the picture, and then save that picture manually into `graph.png`.Fri, 20 Sep 2013 02:06:40 +0200https://ask.sagemath.org/question/10549/graph-theory-exporting-problems/?answer=15473#post-id-15473Answer by Nick.B for <p>I type in the following SAGE code and get the graph on the screen that I would expect to get.</p>
<p>g = Graph({0,[1,2,2]}); g</p>
<p>g.plot(graph_border = True)</p>
<p>When I try to export this to a file with the following code I get an "AssertionError" message.</p>
<p>g = Graph({0,[1,2,2]}); g</p>
<p>g.plot(graph_border = True).save('graph.pdf')</p>
<p>How can I fix this so that I can output this graph as a pdf file. I love how easy I can make nice looking graphs in SAGE, but it is useless if I can't export them to use in Latex.</p>
https://ask.sagemath.org/question/10549/graph-theory-exporting-problems/?answer=15474#post-id-15474Thanks for the reply John. I tried outputting it as a png file and I don't get the error message anymore. But, when I evaluate the two lines of code I get the graph without a link to the file. Where do I find the file?
It is strange I was watching Will Stein's graph theory tutorial and typing exactly as he did and it didn't work for me on my computer. When he typed the code I suggested in the original question he got a link to a pdf file, which he could click on and then have access to the file.Fri, 20 Sep 2013 11:18:11 +0200https://ask.sagemath.org/question/10549/graph-theory-exporting-problems/?answer=15474#post-id-15474