On Thu, May 14, 2009 at 2:03 PM, Jae-Joon Lee <lee.j.j...@gmail.com> wrote:

> On Thu, May 14, 2009 at 4:36 AM, Ben Coppin <cop...@gmail.com> wrote:
> > Hi,
> >
> > I've added annotations to a graph I am producing using matplotlib. The
> > annotations work fine, but when you zoom and pan, the annotations move
> off
> > the edge of the chart and are still visible while they're in the main TK
> > window. Does anyone know of a way to make the annotations disappear when
> > they move off the edge of the chart?
>
> Currently, there is no support for this. However, a monkey patching
> can be a quick solution for now.
>
>
> from matplotlib.text import Annotation
>
> def draw(self, renderer):
>    x, y = self.xy
>    x, y = self._get_xy(x, y, self.xycoords)
>    if not self.axes.bbox.contains(x, y):
>        return
>
>    self.draw_real(renderer)
>
> Annotation.draw_real = Annotation.draw
> Annotation.draw = draw
>
> ann = annotate("test", (0.5, 0.5), xytext=(0.6, 0.6),
>               arrowprops=dict(arrowstyle="->"))
>
>
> I think this should be the default behavior (with optionally turned
> off). If other developers don't object, i'll try to push this feature
> into the svn.


You can't do this using the existing support for clipping artists?  I was
planning on cooking up an example that did just that, but haven't yet found
the time.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to