[Matplotlib-users] problems with autoscale_view

2010-08-28 Thread xyz
Hello,
If I use autoscale_view than:
* plt.text appears outside x and y coordinates
* and the coordinates starts do not from 0 whereas I use ax.set_xlim(0) 
and ax.set_ylim(0)

What did I wrong?

from pylab import *
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
y1 = [20, 24, 8, 4, 12, 22, 31, 25, 15, 28, 12, 27, 22, 22, 27, 14, 32, 
28, 8, 17, 2, 8, 29, 13, 14, 20, 11, 28, 8]
y2= [2, 32, 28, 1, 22, 11, 14, 27, 3, 31, 12, 20, 32, 24, 24, 16, 7, 10, 
12, 11, 3, 32, 10, 20, 14, 14, 3, 25, 14]
point_labels1 = ['A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 
'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 
'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1']
point_labels2 = ['B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 
'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 
'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1']

fig = plt.figure()
ax = fig.add_subplot(111)

ax.set_title('The red point should be on the path')

plt.plot(x, y1, 'bo', x, y2, 'go')
ax.grid(True)
ax.set_xlim(0.0)
ax.set_ylim(0.0)

fig.autofmt_xdate()

plt.xticks(range(0, 40, 1))

plt.yticks(range(0, 40, 1))
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.legend(('Model length', 'Data length'),
'best', shadow=True, fancybox=True)

for i, label in enumerate(y1):
   plt.text (x[i], y1[i]+0.2, label,
 horizontalalignment='center' )

for i, label in enumerate(y2):
   plt.text (x[i], y2[i]+0.2, label,
 horizontalalignment='center' )


ax.autoscale_view()
plt.savefig('test.png')
plt.show()



--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting an arrow outside of the plot does not work any more

2010-08-28 Thread Jae-Joon Lee
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  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
>>  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
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>
> --
> 
>
> 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: http://www.bgc-jena.mpg.de/~sschym
>
> Biospheric Theory and Modelling Group
> http://www.bgc-jena.mpg.de/bgc-theory/
> _
>
>

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting an arrow outside of the plot does not work any more

2010-08-28 Thread Jason Grout
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.
>


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

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting an arrow outside of the plot does not work any more

2010-08-28 Thread Stan Schymanski
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  
> 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
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>  

-- 


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: http://www.bgc-jena.mpg.de/~sschym

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


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot2grid weird for non-square shapes

2010-08-28 Thread Jae-Joon Lee
Thanks for reporting.
It turns out a (major) bug in gridspec, which should be fixed in r8667 & r8668.
You code should work (except the rowspan and colspan needs to be
exchanged for ax3 and ax4).

Regards,

-JJ



On Sat, Aug 28, 2010 at 2:17 PM, Erik Tollerud  wrote:
> If been playing around with the new Gridspec and subplot2grid stuff,
> and it's pretty cool... one thing is confusing me though: It doesn't
> seem to make any sense if the grid is non-square.  For example,
> suppose a 2x6 grid, which I will number like so:
>
> 1 3 5 7 9   11
> 2 4 6 8 10 12
> I want ax1 to take up 1,2,3, and 4; ax2 to be 5,6,7,8; ax3 should be 9
> and 11; and ax4 should be 10 and 12.  My assumption would be to do
> this:
>
> ax1=plt.subplot2grid((2,6),(0,0),rowspan=2,colspan=2)
> ax2=plt.subplot2grid((2,6),(0,2),rowspan=2,colspan=2)
> ax3=plt.subplot2grid((2,6),(0,4),rowspan=2,colspan=1)
> ax4=plt.subplot2grid((2,6),(1,4),rowspan=2,colspan=1)
>
> But instead, apparently random partterns of axes appear and some to
> override each other so that only one subplot is present in the end...
> what's going on here?
>
> --
> Erik Tollerud
>
> --
> 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
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting an arrow outside of the plot does not work any more

2010-08-28 Thread Jae-Joon Lee
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  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
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Cygwin Install

2010-08-28 Thread Christoph Gohlke


On 8/27/2010 10:13 PM, Adam Gustafson wrote:
> I found a web page in which someone has done the horrible task of
> figuring out how the hell you compile in Cygwin.  Details below:
>
> http://innuendopoly.org/arch/matplotlib-cygwin
>
> In short, the Cygwin compile runs into TONS of errors as is, and it
> seems the matplotlib developers aren't really supporting it.  Trying
> their techniques to see if it works, but so far looking good
>

What a friendly message... Matplotlib builds and works fine on cygwin 
when disabling the tkagg backend in setup.cfg.

--
Christoph

--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] realtime plotting was working with matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0

2010-08-28 Thread Eric Firing
On 08/27/2010 05:17 PM, Chiara Caronna wrote:
> Ok, it is a backend issue:
> I checked and I was using Qt4Agg
> as soon as I changed to TkAgg the script worked fine...
> still is this normal or is it a bug?
> thanks for your suggestion and help!

Chiara,

As a workaround for Qt4Agg, you can follow p.draw() with 
fig.canvas.flush_events().

I think this is a bug that will be fixed easily by incorporating the 
flush functionality in the draw method, but I'm not ready to commit to 
it yet.

I wonder whether you were using a different backend when you were using 
0.99.1.1?  Or a different version of PyQt4?

Eric

> Chiara
>
> 
> From: chiaracaro...@hotmail.com
> To: ben.r...@ou.edu
> Date: Sat, 28 Aug 2010 03:01:54 +
> CC: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] realtime plotting was working with
> matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0
>
> I think I am using TkAgg but I am not sure, how can I check it?
>
> 
> From: ben.r...@ou.edu
> Date: Fri, 27 Aug 2010 21:50:19 -0500
> Subject: Re: [Matplotlib-users] realtime plotting was working with
> matplotlib 0.99.1.1 and it doesn't with matplotlib 1.0.0
> To: chiaracaro...@hotmail.com
> CC: matplotlib-users@lists.sourceforge.net
>
> On Fri, Aug 27, 2010 at 9:26 PM, Chiara Caronna
> mailto:chiaracaro...@hotmail.com>> wrote:
>
> Hi all,
> I have a script to update a plot in real time. It was working fine
> with matplotlib 0.99.1.1 but it doesn't work anymore with the new
> version.
>
> Here is the script:
>
> import numpy as n
> import pylab as p
>
> x=n.arange(10)
> y=n.random.randn(10)
> p.ion()
> fig=p.figure(1)
> ax=fig.add_subplot(111)
> line,=ax.plot(x,y,'ko-')
> for i in range(10):
> y=n.random.randn(10)
> line.set_data(x,y)
> p.draw()
>
>
> it is updating the plot correctly with matplotlib 0.99.1.1
> when I run it with matplotlib 1.0.0
> it doesn't show any picture at all
>
> Interestingly, if I add a line raw_input('ok') then it shows the
> plot and it updates it inside the loop
>
>
> x=n.arange(10)
> y=n.random.randn(10)
> p.ion()
> fig=p.figure(1)
> ax=fig.add_subplot(111)
> line,=ax.plot(x,y,'ko-')
> raw_input('ok?')
> for i in range(10):
> y=n.random.randn(10)
> line.set_data(x,y)
> p.draw()
> raw_input('ok?')
>
> Any idea why it is doing this? Is it a bug or am I missing something?
>
> Thanks for your help,
> Chiara
>
>
> It seems to work fine for me using the GTKAgg backend. Which backend are
> you using? Also, admittedly, this is the trunk build, so it might have
> some fixes that weren't in the release.
>
> Ben Root
>
> --
> 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
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> 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
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users