Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17412bf

Browse files
authored
Merge pull request #26342 from rcomer/cs-set_paths
ENH: Collection.set_paths
2 parents 2aee6cc + 917fdeb commit 17412bf

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
@@ -1002,10 +1003,6 @@ def __init__(self, paths, sizes=None, **kwargs):
10021003
self.set_sizes(sizes)
10031004
self.stale = True
10041005

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

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)