diff --git a/releasenotes/notes/fix-connectionstyles-bug-25a3cab6e6932daa.yaml b/releasenotes/notes/fix-connectionstyles-bug-25a3cab6e6932daa.yaml new file mode 100644 index 0000000000..aac79b5a45 --- /dev/null +++ b/releasenotes/notes/fix-connectionstyles-bug-25a3cab6e6932daa.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixed an issue where using function ``draw_edges()`` in + ~/rustworkx/visualization/matplotlib.py will always attempt to use + connectionstyle arc3 even if a different connectionstyle argument is + input by the user. Now, `draw_edges()` can accept different connectionstyle arguments. + If connectionstyle arc3 is used, the previous `draw_edges()` behavior is still used. + Refer to `#1497 `__ for more details. diff --git a/rustworkx/visualization/matplotlib.py b/rustworkx/visualization/matplotlib.py index 4f9ddbb701..b541ca5d5f 100644 --- a/rustworkx/visualization/matplotlib.py +++ b/rustworkx/visualization/matplotlib.py @@ -731,7 +731,7 @@ def to_marker_edge(marker_size, marker): mutation_scale=mutation_scale, color=arrow_color, linewidth=line_width, - connectionstyle=f"{connectionstyle}, rad = {rad}", + connectionstyle=f"{connectionstyle}, rad = {rad}" if connectionstyle=="arc3" else f"{connectionstyle}", linestyle=style, zorder=1, ) # arrows go behind nodes diff --git a/tests/visualization/test_mpl.py b/tests/visualization/test_mpl.py index 705a5b80f3..9d3a999914 100644 --- a/tests/visualization/test_mpl.py +++ b/tests/visualization/test_mpl.py @@ -204,3 +204,15 @@ def test_hexagonal_lattice_directed(self): plt.close("all") mpl_draw(graph, pos=[graph.get_node_data(n) for n in range(len(graph))]) _save_images(plt.gcf(), "test_hexagonal_lattice_directed.png") + + def test_connectionstyles(self): + G = rustworkx.generators.directed_path_graph(25) + mpl_draw(G, connectionstyle='bar') + _save_images(plt.gcf(), "test_connectionstyle_bar.png") + plt.clf() + mpl_draw(G, connectionstyle='angle, angleA=30, angleB=150, rad=1.3') + _save_images(plt.gcf(), "test_connectionstyle_angle.png") + plt.clf() + mpl_draw(G, connectionstyle='angle3, angleA=20, angleB=60') + _save_images(plt.gcf(), "test_connectionstyle_angle3.png") + plt.clf() \ No newline at end of file