简体   繁体   中英

Why does the NetworkX graph not draw in Cygwin?

I am running Python and NetworkX (a graphing library) on Cygwin (Windows 7).

The following code creates a graph and attempts to draw it - but nothing appears on screen:

plt.ion()
nx.draw(nx.petersen_graph())
plt.show()

There don't appear to be any errors.

I have also tried saving a graph to an image using:

plt.savefig("test.png")

which creates the correct image.

Does this have to do with matplotlib and Cygwin?

I fixed this problem by:

  1. Starting X using startxwin and running the script from there.
  2. Changing the backend = agg setting to backend = tkagg in my matplotlibrc file.

Thanks to tcaswell and EdChum for the help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM