Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw multigraphs example fails to run #7358

Closed
NiklasvonM opened this issue Mar 18, 2024 · 2 comments
Closed

Draw multigraphs example fails to run #7358

NiklasvonM opened this issue Mar 18, 2024 · 2 comments

Comments

@NiklasvonM
Copy link

Current Behavior

The script examples/drawing/plot_multigraphs.py fails to run: Passing the list connectionstyle to nx.draw_networkx_edges raises an AttributeError: "'list' object has no attribute 'replace'".

Expected Behavior

Similar to the user scripts within that example folder, one would expect a graph to be drawn.

Steps to Reproduce

  • Install NetworkX and Matplotlib
  • Run examples/drawing/plot_multigraphs.py

Environment

Python version: 3.12.1
NetworkX version: 3.2.1
Matplotlib version: 3.6.0 and 3.8.3

Error Trace

File "plot_multigraphs.py", line 67, in
draw_labeled_multigraph(G, "w", ax)
File "plot_multigraphs.py", line 37, in draw_labeled_multigraph
nx.draw_networkx_edges(
File "venv\Lib\site-packages\networkx\drawing\nx_pylab.py", line 912, in draw_networkx_edges
edge_viz_obj = _draw_networkx_edges_fancy_arrow_patch()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv\Lib\site-packages\networkx\drawing\nx_pylab.py", line 778, in _draw_networkx_edges_fancy_arrow_patch
base_connection_style = mpl.patches.ConnectionStyle(connectionstyle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv\Lib\site-packages\matplotlib\patches.py", line 2212, in new
_list = stylename.replace(" ", "").split(",")
^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'replace'

@mohamedrezk122
Copy link
Contributor

It works fine with
development version of networkx
Matplotlib: 3.8.3

I guess it is fixed in #7010

image

@rossbar
Copy link
Contributor

rossbar commented Mar 19, 2024

Yes, multigraph edge drawing was added in #7010 which is not yet included in a released version of NetworkX. This will be available in the next NetworkX version (3.3). The reason you're seeing the discrepancy with the docs is because the gallery example is included in the latest docs (i.e. built from main). To limit documentation to only those features that are in the latest stable release, see https://networkx.org/documentation/stable/

@rossbar rossbar closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants