# Graph theory exporting problems

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

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.

edit retag close merge delete

Sort by » oldest newest most voted

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

Thanks 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.

more

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

Save 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.

more