1

I'm trying to make a program showing step-by-step changes from Networkx algorithms. (Dijkstra, Shortest augmenting path)

Using nx.draw(G, node_size = size) I could change the size of graph nodes, but those sizes seem to be relative to display size, which means, if I change the resulting plt.show() figure window size, all the graph attributes (i.e. edges, labels, some texts) change according to the window size, but node sizes are fixed.

How can I make the node size change with the window size? Do I need to use my own codes from matplotlib?

image1: Initial plt.show() result

image2: When I stretch the window, graph gets distorted.

  • Did you want to have the update to node sizes dynamically while you change the window size? `nx.draw` uses `matplotlib.pyplot.scatter` underneath so you might find a solution this way. – Bonlenfum Feb 01 '17 at 18:47
  • ah, but a different way to go might be to reformulate your question. You can define the window size, with `fig = plt.figure(num=1, figsize=(10,5))`; and you could define the node size relative to the figure size, so both parts are controlled centrally. You can also control the *ratio* of the axes with resizes, e.g. via `plt.axis('equal')`. If you want a dynamic solution, that likely needs more work, but this route is simpler. – Bonlenfum Feb 01 '17 at 18:54
  • @Bonlenfum Thanks for comment. I found an valid solution to my problem from [this](http://stackoverflow.com/questions/27319209/how-to-set-a-fixed-static-size-of-circle-marker-on-a-scatter-plot) – Sanghyun Baek Feb 08 '17 at 03:22

0 Answers0