-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mpl_draw() to fix multigraph plots (#1204)
* Update #1: Fixing mpl_draw() for multigraphs * Update matplotlib.py for formatting * Update rustworkx/visualization/matplotlib.py Co-authored-by: Ivan Carvalho <[email protected]> * Update matplotlib.py to remove the loop * Add releasenotes * Reformat connectionstyle string in rustworkx/visualization/matplotlib.py Co-authored-by: Ivan Carvalho <[email protected]> * Fixes #774 * Optimize edge search by using sets --------- Co-authored-by: Ivan Carvalho <[email protected]>
- Loading branch information
1 parent
c7a7d53
commit 646057a
Showing
2 changed files
with
91 additions
and
46 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
releasenotes/notes/fix-mpl-draw-digraph-plots-aecf86738ab9b0db.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed the plots of multigraphs using :func:`.mpl_draw`. Previously, parallel edges of | ||
multigraphs were plotted on top of each other, with overlapping arrows and labels. | ||
The radius of parallel edges of the multigraph was fixed to be `0.25` for | ||
`connectionstyle` supporting this argument in :func:`.draw_edges`. The edge lables | ||
were offset to `0.25` in :func:`.draw_edge_labels` to align with their respective | ||
edges. This fix can be tested using the following code: | ||
.. jupyter-execute:: | ||
import rustworkx | ||
from rustworkx.visualization import mpl_draw | ||
graph = rustworkx.PyDiGraph() | ||
graph.add_node('A') | ||
graph.add_node('B') | ||
graph.add_node('C') | ||
graph.add_edge(1, 0, 2) | ||
graph.add_edge(0, 1, 3) | ||
graph.add_edge(1, 2, 4) | ||
mpl_draw(graph, with_labels=True, labels=str, edge_labels=str, alpha=0.5) | ||
- | | ||
Refer to `#774 <https://github.com/Qiskit/rustworkx/issues/774>` for more | ||
details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters