8000 Deprecate public use of get_path_in_displaycoord. by anntzer · Pull Request #20428 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Deprecate public use of get_path_in_displaycoord. #20428

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
Jun 14, 2021
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
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/20428-AL.rst
Original file line number Diff line number Diff line change
@@ -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())``.
22 changes: 12 additions & 10 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -4389,18 +4387,22 @@ 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

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]
Expand Down Expand Up @@ -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)
Expand Down
0