diff --git a/doc/api/next_api_changes/deprecations/20428-AL.rst b/doc/api/next_api_changes/deprecations/20428-AL.rst new file mode 100644 index 000000000000..3de56e880afc --- /dev/null +++ b/doc/api/next_api_changes/deprecations/20428-AL.rst @@ -0,0 +1,4 @@ +``FancyArrowPatch.get_path_in_displaycoord`` and ``ConnectionPath.get_path_in_displaycoord`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +... are deprecated. The path in display coordinates can still be obtained, as +for other patches, using ``patch.get_transform().transform_path(patch.get_path())``. diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 5ff6908510bf..50f7e6f2c8a3 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -4354,17 +4354,15 @@ def get_mutation_aspect(self): else 1) # backcompat. def get_path(self): - """ - Return the path of the arrow in the data coordinates. Use - get_path_in_displaycoord() method to retrieve the arrow path - in display coordinates. - """ - _path, fillable = self.get_path_in_displaycoord() + """Return the path of the arrow in the data coordinates.""" + # The path is generated in display coordinates, then converted back to + # data coordinates. + _path, fillable = self._get_path_in_displaycoord() if np.iterable(fillable): _path = Path.make_compound_path(*_path) return self.get_transform().inverted().transform_path(_path) - def get_path_in_displaycoord(self): + def _get_path_in_displaycoord(self): """Return the mutated path of the arrow in display coordinates.""" dpi_cor = self._dpi_cor @@ -4389,6 +4387,10 @@ def get_path_in_displaycoord(self): return _path, fillable + get_path_in_displaycoord = _api.deprecate_privatize_attribute( + "3.5", + alternative="self.get_transform().transform_path(self.get_path())") + def draw(self, renderer): if not self.get_visible(): return @@ -4396,11 +4398,11 @@ def draw(self, renderer): with self._bind_draw_path_function(renderer) as draw_path: # FIXME : dpi_cor is for the dpi-dependency of the linewidth. There - # could be room for improvement. Maybe get_path_in_displaycoord + # could be room for improvement. Maybe _get_path_in_displaycoord # could take a renderer argument, but get_path should be adapted # too. self._dpi_cor = renderer.points_to_pixels(1.) - path, fillable = self.get_path_in_displaycoord() + path, fillable = self._get_path_in_displaycoord() if not np.iterable(fillable): path = [path] @@ -4612,7 +4614,7 @@ def get_annotation_clip(self): """ return self._annotation_clip - def get_path_in_displaycoord(self): + def _get_path_in_displaycoord(self): """Return the mutated path of the arrow in display coordinates.""" dpi_cor = self._dpi_cor posA = self._get_xy(self.xy1, self.coords1, self.axesA)