plotting an arrow outside of the plot does not work any more

Dear all,

I don't know which update it was that broke it, but this used to work:

import numpy
import pylab
pylab.clf()
fig = pylab.figure(1,figsize=(8,5))
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),
ylim=(-4,3))

t = numpy.arange(0.0, 5.0, 0.01)
s = numpy.cos(2*numpy.pi*t)
line, = ax.plot(t, s, lw=3, color='purple')
pylab.text(-0.5,3.2,'no data',ha='center')
pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',arrowprops=dict(arrowstyle='<->'))
pylab.savefig('blah.png')

This used to plot an arrow under the text 'no data' but above the main plot. Now this arrow does not appear unless at least part of it is within the plotting area. Change one of the '3.1' in the code above to, say, 3.0 and the whole arrow is displayed. Is this a bug or is there a new way of achieving what I want?

Thanks for your help already!

Cheers
Stan

I wonder if it was one of the fixes to the clipping code. If I plot this to the screen and then move the plot so that the “no data” text is in the plot area, the arrow shows up.

So, the question is… was plotting arrows outside the plot area a bug or a feature? And, if it was a bug, what about being able to annotate outside the plot area?

Lastly, whatever the outcome, this example should probably become a test because it would be a great way to test for obscure broken behavior.

Ben Root

P.S. - cc’ing the devel mailing list here…

···

On Fri, Aug 27, 2010 at 7:21 AM, Stan Schymanski <sschym@…3252…> wrote:

Dear all,

I don’t know which update it was that broke it, but this used to work:

import numpy

import pylab

pylab.clf()

fig = pylab.figure(1,figsize=(8,5))

ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),

ylim=(-4,3))

t = numpy.arange(0.0, 5.0, 0.01)

s = numpy.cos(2numpy.pit)

line, = ax.plot(t, s, lw=3, color=‘purple’)

pylab.text(-0.5,3.2,‘no data’,ha=‘center’)

pylab.annotate(‘’,(-1,3.1),(0,3.1),va=‘center’,ha=‘center’,arrowprops=dict(arrowstyle=‘<->’))

pylab.savefig(‘blah.png’)

This used to plot an arrow under the text ‘no data’ but above the main plot. Now this arrow does not appear unless at least part of it is within the plotting area. Change one of the ‘3.1’ in the code above to, say, 3.0 and the whole arrow is displayed. Is this a bug or is there a new way of achieving what I want?

Thanks for your help already!

Cheers

Stan

I think this change has been there for a while.
For recent versions of matplotlib, the default behavior of annotate is
that, when xycoords=="data", the arrow is drawn only when the
annotated point is inside the axes.
To override this behavior, use annotation_clip keyword parameter.

pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',
               arrowprops=dict(arrowstyle='<->'), annotation_clip=False)

Regards,

-JJ

···

On Fri, Aug 27, 2010 at 9:21 PM, Stan Schymanski <sschym@...3251...> wrote:

Dear all,

I don't know which update it was that broke it, but this used to work:

import numpy
import pylab
pylab.clf()
fig = pylab.figure(1,figsize=(8,5))
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),
ylim=(-4,3))

t = numpy.arange(0.0, 5.0, 0.01)
s = numpy.cos(2*numpy.pi*t)
line, = ax.plot(t, s, lw=3, color='purple')
pylab.text(-0.5,3.2,'no data',ha='center')
pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',arrowprops=dict(arrowstyle='<->'))
pylab.savefig('blah.png')

This used to plot an arrow under the text 'no data' but above the main plot. Now this arrow does not appear unless at least part of it is within the plotting area. Change one of the '3.1' in the code above to, say, 3.0 and the whole arrow is displayed. Is this a bug or is there a new way of achieving what I want?

Thanks for your help already!

Cheers
Stan

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi JJ,

Thanks for the advice. However, the annotation_clip=False addition does not make a difference to me. I am using Matplotlib from within Sage, though; not sure if this makes it behave differently.

Cheers
Stan

···

On 8/28/10 5:09 PM, Jae-Joon Lee wrote:

I think this change has been there for a while.
For recent versions of matplotlib, the default behavior of annotate is
that, when xycoords=="data", the arrow is drawn only when the
annotated point is inside the axes.
To override this behavior, use annotation_clip keyword parameter.

pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',
                arrowprops=dict(arrowstyle='<->'), annotation_clip=False)

Regards,

-JJ

On Fri, Aug 27, 2010 at 9:21 PM, Stan Schymanski<sschym@...3251...> wrote:
   

Dear all,

I don't know which update it was that broke it, but this used to work:

import numpy
import pylab
pylab.clf()
fig = pylab.figure(1,figsize=(8,5))
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),
ylim=(-4,3))

t = numpy.arange(0.0, 5.0, 0.01)
s = numpy.cos(2*numpy.pi*t)
line, = ax.plot(t, s, lw=3, color='purple')
pylab.text(-0.5,3.2,'no data',ha='center')
pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',arrowprops=dict(arrowstyle='<->'))
pylab.savefig('blah.png')

This used to plot an arrow under the text 'no data' but above the main plot. Now this arrow does not appear unless at least part of it is within the plotting area. Change one of the '3.1' in the code above to, say, 3.0 and the whole arrow is displayed. Is this a bug or is there a new way of achieving what I want?

Thanks for your help already!

Cheers
Stan

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
________________________________________

Stan Schymanski
Scientist
Max Planck Institute for Biogeochemistry
PO Box 10 01 64
D-07701 Jena, Germany

Phone: +49.3641.576264
Fax: +49.3641.577274
WWW: Startseite | Max-Planck-Institut für Biogeochemie

Biospheric Theory and Modelling Group
http://www.bgc-jena.mpg.de/bgc-theory/
_________________________________________

FYI, matplotlib in Sage is still at matplotlib 0.99.3. We're working on upgrading it to 1.0.0.

Stan, if you want, could you try installing the 1.0.0 Sage matplotlib spkg and seeing if that works? You can do it by doing:

sage -i http://sage.math.washington.edu/home/jason/matplotlib-1.0.0.spkg

(the ticket is http://trac.sagemath.org/sage_trac/ticket/9221 )

Matplotlib 1.0.0 changes how axes labels work, so if you want to do axes labels, then you'll have to also install the patch listed at the ticket.

Thanks,

Jason

···

On 8/28/10 3:59 PM, Stan Schymanski wrote:

Hi JJ,

Thanks for the advice. However, the annotation_clip=False addition does
not make a difference to me. I am using Matplotlib from within Sage,
though; not sure if this makes it behave differently.

I just remembered that there has been a bug in old version of
matplotlib that annotation_clip parameter is not correctly set when
given as a keyword parameter of "annotate" function. The bug has been
fixed.

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg15068.html

As a workaround, use

ann = pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',
              arrowprops=dict(arrowstyle='<->'))
ann.set_annotation_clip(False)

Regards,

-JJ

···

On Sun, Aug 29, 2010 at 5:59 AM, Stan Schymanski <sschym@...3251...> wrote:

Hi JJ,

Thanks for the advice. However, the annotation_clip=False addition does not
make a difference to me. I am using Matplotlib from within Sage, though; not
sure if this makes it behave differently.

Cheers
Stan

On 8/28/10 5:09 PM, Jae-Joon Lee wrote:

I think this change has been there for a while.
For recent versions of matplotlib, the default behavior of annotate is
that, when xycoords=="data", the arrow is drawn only when the
annotated point is inside the axes.
To override this behavior, use annotation_clip keyword parameter.

pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',
arrowprops=dict(arrowstyle='<->'), annotation_clip=False)

Regards,

-JJ

On Fri, Aug 27, 2010 at 9:21 PM, Stan Schymanski<sschym@...3251...> >> wrote:

Dear all,

I don't know which update it was that broke it, but this used to work:

import numpy
import pylab
pylab.clf()
fig = pylab.figure(1,figsize=(8,5))
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),
ylim=(-4,3))

t = numpy.arange(0.0, 5.0, 0.01)
s = numpy.cos(2*numpy.pi*t)
line, = ax.plot(t, s, lw=3, color='purple')
pylab.text(-0.5,3.2,'no data',ha='center')

pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',arrowprops=dict(arrowstyle='<->'))
pylab.savefig('blah.png')

This used to plot an arrow under the text 'no data' but above the main
plot. Now this arrow does not appear unless at least part of it is within
the plotting area. Change one of the '3.1' in the code above to, say, 3.0
and the whole arrow is displayed. Is this a bug or is there a new way of
achieving what I want?

Thanks for your help already!

Cheers
Stan

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue
and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
________________________________________

Stan Schymanski
Scientist
Max Planck Institute for Biogeochemistry
PO Box 10 01 64
D-07701 Jena, Germany

Phone: +49.3641.576264
Fax: +49.3641.577274
WWW: Startseite | Max-Planck-Institut für Biogeochemie

Biospheric Theory and Modelling Group
http://www.bgc-jena.mpg.de/bgc-theory/
_________________________________________

This worked great, thanks so much for your help!

Cheers
Stan

···

On 8/29/10 2:29 AM, Jae-Joon Lee wrote:

I just remembered that there has been a bug in old version of
matplotlib that annotation_clip parameter is not correctly set when
given as a keyword parameter of "annotate" function. The bug has been
fixed.

Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing

As a workaround, use

ann = pylab.annotate('',(-1,3.1),(0,3.1),va='center',ha='center',
               arrowprops=dict(arrowstyle='<->'))
ann.set_annotation_clip(False)

Regards,

-JJ