ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 01 Oct 2014 07:34:30 -0500Graph plotting in SMChttps://ask.sagemath.org/question/24318/graph-plotting-in-smc/ I was trying to plot some graphs in SMC. However, even the first example given in **[Graph Plotting](http://www.sagemath.org/doc/reference/plotting/sage/graphs/graph_plot.html)** doesn't work. I only got an empty output. The following is the example i was trying.
<code>sage: G = graphs.WheelGraph(15)</code>
<code>sage: G.plot()</code>
What am I missing in my example?
P.S.: Yes. The example works in Sage worksheets, however, it doesn't work in iPython notebook. How to make it work in iPython notebook?Sun, 28 Sep 2014 00:41:29 -0500https://ask.sagemath.org/question/24318/graph-plotting-in-smc/Comment by dazedANDconfused for <p>I was trying to plot some graphs in SMC. However, even the first example given in <strong><a href="http://www.sagemath.org/doc/reference/plotting/sage/graphs/graph_plot.html">Graph Plotting</a></strong> doesn't work. I only got an empty output. The following is the example i was trying.</p>
<p><code>sage: G = graphs.WheelGraph(15)</code></p>
<p><code>sage: G.plot()</code></p>
<p>What am I missing in my example?</p>
<p>P.S.: Yes. The example works in Sage worksheets, however, it doesn't work in iPython notebook. How to make it work in iPython notebook?</p>
https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24320#post-id-24320Nothing missing; the code works in a [Sage Cell Server](https://sagecell.sagemath.org/).Sun, 28 Sep 2014 09:17:26 -0500https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24320#post-id-24320Answer by calc314 for <p>I was trying to plot some graphs in SMC. However, even the first example given in <strong><a href="http://www.sagemath.org/doc/reference/plotting/sage/graphs/graph_plot.html">Graph Plotting</a></strong> doesn't work. I only got an empty output. The following is the example i was trying.</p>
<p><code>sage: G = graphs.WheelGraph(15)</code></p>
<p><code>sage: G.plot()</code></p>
<p>What am I missing in my example?</p>
<p>P.S.: Yes. The example works in Sage worksheets, however, it doesn't work in iPython notebook. How to make it work in iPython notebook?</p>
https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?answer=24323#post-id-24323Try the following code in ipython in SMC to load the sage commands and the networkx library. Then, you can see the graph.
from sage.all import *
import networkx as nx
G = graphs.WheelGraph(15)
H=G.networkx_graph()
nx.draw(H)
plt.savefig("simple_path.png")
plt.show()Sun, 28 Sep 2014 18:25:31 -0500https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?answer=24323#post-id-24323Comment by Han for <p>Try the following code in ipython in SMC to load the sage commands and the networkx library. Then, you can see the graph.</p>
<pre><code>from sage.all import *
import networkx as nx
G = graphs.WheelGraph(15)
H=G.networkx_graph()
nx.draw(H)
plt.savefig("simple_path.png")
plt.show()
</code></pre>
https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24326#post-id-24326I'm afraid the code cannot return what I expected. Yes, it returns a Wheel graph with 15 vertices. But the graph drawn there is ugly. Thank you for sharing anyway.Mon, 29 Sep 2014 10:27:03 -0500https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24326#post-id-24326Comment by calc314 for <p>Try the following code in ipython in SMC to load the sage commands and the networkx library. Then, you can see the graph.</p>
<pre><code>from sage.all import *
import networkx as nx
G = graphs.WheelGraph(15)
H=G.networkx_graph()
nx.draw(H)
plt.savefig("simple_path.png")
plt.show()
</code></pre>
https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24364#post-id-24364I get the same graph in iPython as in Sage. There are some formatting options for graphs that can be used in Sage. I imagine that networkx has similar options that might allow you to get the format that you want.Wed, 01 Oct 2014 07:34:30 -0500https://ask.sagemath.org/question/24318/graph-plotting-in-smc/?comment=24364#post-id-24364