The way Annotation.draw (in text.py) is implemented, if an annotation
is created with an annotation point (x,y) and text located at (tx,ty)
and then the you pan around on the graph such that (x,y) is no longer
visible, the annotation suddenly disappears.
I would suggest the following modification to Annotation.draw in
text.py. All it does is set a clip box so that the annotation and
arrow is still drawn, but the arrow is clipped at the axes boundary.
It is a much nicer effect than the annotation disappearing. I have
made this modification in my source locally, and it works very well,
but I thought I would suggest here for inclusion into the main code
Modified lines are marked with a CHANGEME. It is only a four line change.
def draw(self, renderer):
Draw the :class:`Annotation` object to the given *renderer*.
if renderer is not None:
self._renderer = renderer
if not self.get_visible(): return
xy_pixel = self._get_position_xy(renderer)
#if not self._check_xy(renderer, xy_pixel): CHANGEME (commented out)
CHANGEME (commented out)
if self.arrow is not None:
if self.arrow.figure is None and self.figure is not None:
self.arrow.figure = self.figure
self.arrow.set_clip_box(self.axes.bbox) # CHANGEME (new line)
if self.arrow_patch is not None:
if self.arrow_patch.figure is None and self.figure is not None:
self.arrow_patch.figure = self.figure
self.arrow_patch.set_clip_box(self.axes.bbox) # CHANGEME (new line)