Skip to content

Commit 917fdeb

Browse files
committed
ENH: Collection.set_paths
1 parent 2a4d905 commit 917fdeb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/matplotlib/collections.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def get_paths(self):
207207
return self._paths
208208

209209
def set_paths(self, paths):
210-
raise NotImplementedError
210+
self._paths = paths
211+
self.stale = True
211212

212213
def get_transforms(self):
213214
return self._transforms
@@ -1001,10 +1002,6 @@ def __init__(self, paths, sizes=None, **kwargs):
10011002
self.set_sizes(sizes)
10021003
self.stale = True
10031004

1004-
def set_paths(self, paths):
1005-
self._paths = paths
1006-
self.stale = True
1007-
10081005
def get_paths(self):
10091006
return self._paths
10101007

lib/matplotlib/tests/test_contour.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from matplotlib import pyplot as plt, rc_context, ticker
1212
from matplotlib.colors import LogNorm, same_color
1313
import matplotlib.patches as mpatches
14-
from matplotlib.testing.decorators import image_comparison
14+
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1515
import pytest
1616

1717

@@ -100,6 +100,14 @@ def test_contour_Nlevels():
100100
assert (cs1.levels == cs2.levels).all()
101101

102102

103+
@check_figures_equal(extensions=['png'])
104+
def test_contour_set_paths(fig_test, fig_ref):
105+
cs_test = fig_test.subplots().contour([[0, 1], [1, 2]])
106+
cs_ref = fig_ref.subplots().contour([[1, 0], [2, 1]])
107+
108+
cs_test.set_paths(cs_ref.get_paths())
109+
110+
103111
@pytest.mark.parametrize("split_collections", [False, True])
104112
@image_comparison(['contour_manual_labels'], remove_text=True, style='mpl20', tol=0.26)
105113
def test_contour_manual_labels(split_collections):

0 commit comments

Comments
 (0)