Skip to content

Commit 39d437f

Browse files
committed
fix: fix plotting of null graphs with the Matplotlib backend
1 parent 98b0c93 commit 39d437f

8 files changed

Lines changed: 854 additions & 1 deletion

File tree

src/igraph/drawing/matplotlib/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def _draw_vertices(self):
532532

533533
art = VertexCollection(
534534
patches,
535-
offsets=offsets,
535+
offsets=offsets if offsets else None,
536536
offset_transform=self.axes.transData,
537537
match_original=True,
538538
transform=Affine2D(),
2.3 KB
Loading

tests/drawing/cairo/test_graph.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def test_graph_with_curved_edges(self):
8585
backend="cairo",
8686
)
8787

88+
@image_comparison(baseline_images=["graph_null"])
89+
def test_null_graph(self):
90+
g = Graph()
91+
plot(g, backend="cairo", target=result_image_folder / "graph_null.png")
92+
8893

8994
class ClusteringTestRunner(unittest.TestCase):
9095
@classmethod
3.25 KB
Loading

tests/drawing/matplotlib/test_graph.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def test_graph_with_curved_edges(self):
155155
)
156156
ax.set_aspect(1.0)
157157

158+
@image_comparison(baseline_images=["graph_null"])
159+
def test_null_graph(self):
160+
plt.close("all")
161+
g = Graph()
162+
fig, ax = plt.subplots()
163+
plot(g, target=ax)
164+
ax.set_aspect(1.0)
165+
158166

159167
class ClusteringTestRunner(unittest.TestCase):
160168
def setUp(self):

0 commit comments

Comments
 (0)