Search code examples
pythonmatplotlibnetworkx

nodes not drawn near edges with draw_networkx


The plot that networkx.draw_networkx() returns is not correct. The node points and edge lines are not attached in the plot. Also, the scale of the plot is too great and the nodes and edges appear very small and uncentered.

The image below is the output from an example from the networkx documentation:

G = nx.complete_graph(5)

nx.draw_networkx(G)

example of my plots

I have reinstalled the networkx and matplotlib packages.


Solution

  • Issue resolved.

    I was using an old version of networkx (2.8). I upgraded to version 3.2.1 and now my plots are drawing correctly.

    pip install --upgrade --force-reinstall networkx