I am attempting to display graphs without saving them using matplotlib in Sublime. For some odd reason, plt.show() is not working. There are no compilation errors or any other hints that would be useful.
import networkx as nx
import matplotlib.pyplot as plt
import random as r
randNum = r.randint(2,10)
randGraph = randStarGraph(randNum)
plt.show()
Anybody have any ideas?
Edit: I tried running Sait's code in Sublime. The graph failed to show. I ran the script from cmd, and the graph was successfully displayed on the screen, so it seems to be an issue with Sublime.
答案 0 :(得分:1)
What is randStarGraph()
doing and where is it defined?
Also, you don't call nx.draw()
here, do you do it somewhere else?
You can test if sublime is working well with the following example:
import networkx as nx
import matplotlib.pyplot as plt
g = nx.complete_graph(5)
nx.draw(g)
plt.show()
答案 1 :(得分:0)
在尝试上面提到的修复后,我升级到Sublime 3,这解决了我的问题。我以前没有真正考虑升级,但是现在我对版本3提供的新功能印象深刻。