8000 ENH: Collection.set_paths by rcomer · Pull Request #26342 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

ENH: Collection.set_paths #26342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def get_paths(self):
return self._paths

def set_paths(self, paths):
raise NotImplementedError
self._paths = paths
self.stale = True

def get_transforms(self):
return self._transforms
Expand Down Expand Up @@ -1001,10 +1002,6 @@ def __init__(self, paths, sizes=None, **kwargs):
self.set_sizes(sizes)
self.stale = True

def set_paths(self, paths):
self._paths = paths
self.stale = True

def get_paths(self):
return self._paths

Expand Down
10 changes: 9 additions & 1 deletion lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from matplotlib import pyplot as plt, rc_context, ticker
from matplotlib.colors import LogNorm, same_color
import matplotlib.patches as mpatches
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.decorators import check_figures_equal, image_comparison
import pytest


Expand Down Expand Up @@ -100,6 +100,14 @@ def test_contour_Nlevels():
assert (cs1.levels == cs2.levels).all()


@check_figures_equal(extensions=['png'])
def test_contour_set_paths(fig_test, fig_ref):
cs_test = fig_test.subplots().contour([[0, 1], [1, 2]])
cs_ref = fig_ref.subplots().contour([[1, 0], [2, 1]])

cs_test.set_paths(cs_ref.get_paths())


@pytest.mark.parametrize("split_collections", [False, True])
@image_comparison(['contour_manual_labels'], remove_text=True, style='mpl20', tol=0.26)
def test_contour_manual_labels(split_collections):
Expand Down
0