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

Skip to content

stale artists do not handle being removed from axes properly #4902

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

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 4 additions & 2 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ def draw_wrapper(artist, renderer, *args, **kwargs):


def _stale_figure_callback(self):
self.figure.stale = True
if self.figure:
self.figure.stale = True


def _stale_axes_callback(self):
self.axes.stale = True
if self.axes:
self.axes.stale = True


class Artist(object):
Expand Down
34 changes: 25 additions & 9 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def contains(self, mouseevent):

def _get_xy_display(self):
'get the (possibly unit converted) transformed x, y in display coords'
x, y = self.get_position()
x, y = self._get_unitless_position()
return self.get_transform().transform_point((x, y))

def _get_multialignment(self):
Expand Down Expand Up @@ -536,8 +536,8 @@ def update_bbox_position_size(self, renderer):

trans = self.get_transform()

# don't use self.get_position here, which refers to text position
# in Text, and dash position in TextWithDash:
# don't use self._get_unitless position here, which refers to text
# position in Text, and dash position in TextWithDash:
posx = float(self.convert_xunits(self._x))
posy = float(self.convert_yunits(self._y))

Expand Down Expand Up @@ -877,12 +877,20 @@ def get_horizontalalignment(self):
"""
return self._horizontalalignment

def get_position(self):
"Return the position of the text as a tuple (*x*, *y*)"
def _get_unitless_position(self):
"Return the unitless position of the text as a tuple (*x*, *y*)"
# This will get the position with all unit information stripped away.
# This is here for convienience since it is done in several locations.
x = float(self.convert_xunits(self._x))
y = float(self.convert_yunits(self._y))
return x, y

def get_position(self):
"Return the position of the text as a tuple (*x*, *y*)"
# This should return the same data (possible unitized) as was
# specified with 'set_x' and 'set_y'.
return self._x, self._y

def get_prop_tup(self):
"""
Return a hashable tuple of properties.
Expand All @@ -891,7 +899,7 @@ def get_prop_tup(self):
want to cache derived information about text (e.g., layouts) and
need to know if the text has changed.
"""
x, y = self.get_position()
x, y = self._get_unitless_position()
return (x, y, self.get_text(), self._color,
self._verticalalignment, self._horizontalalignment,
hash(self._fontproperties),
Expand Down Expand Up @@ -1365,12 +1373,20 @@ def __init__(self,

#self.set_bbox(dict(pad=0))

def get_position(self):
"Return the position of the text as a tuple (*x*, *y*)"
def _get_unitless_position(self):
"Return the unitless position of the text as a tuple (*x*, *y*)"
# This will get the position with all unit information stripped away.
# This is here for convienience since it is done in several locations.
x = float(self.convert_xunits(self._dashx))
y = float(self.convert_yunits(self._dashy))
return x, y

def get_position(self):
"Return the position of the text as a tuple (*x*, *y*)"
# This should return the same data (possibly unitized) as was
# specified with set_x and set_y
return self._dashx, self._dashy

def get_prop_tup(self):
"""
Return a hashable tuple of properties.
Expand Down Expand Up @@ -1402,7 +1418,7 @@ def update_coords(self, renderer):
with respect to the actual canvas's coordinates we need to map
back and forth.
"""
dashx, dashy = self.get_position()
dashx, dashy = self._get_unitless_position()
dashlength = self.get_dashlength()
# Shortcircuit this process if we don't have a dash
if dashlength == 0.0:
Expand Down