Re: [Matplotlib-users] Cursor corruption with pyqt4 and a work-around.

2010-06-18 Thread Darren Dale
On Thu, Jun 17, 2010 at 11:04 PM, David Smith  wrote:
> I have been developing an application using PyQt ant Matplotlib and 
> encountered
> a problem with the mouse cursor shape being incorrect.  I found a work-around
> that seems to work, but I think this is a bug and the fix needs to go into the
> Matplotlib code base. Here are details.
>
> My application has a central widget used fo r a Matplotlib Figure.
>  Additionally there is a menu bar, button bar and two dock panels with
>  controls for the plot.  I see the following behavior for the cursor:
>
> * On start up, the cursor acts normally on startup provided
>  the mouse cursor is not inside the figure widget on start-up.
>
> * Mouse pointer shapes are set by Windows (in this case VISTA)
>  and change shape according to location.  For example, touching
>  the application window's border results in the arrow pointer
>  changing shape to a double-headed arrow indicating the border
>  can be dragged to adjust the size of the window.
>
> * Once the mouse pointer touches the Matplotlib figure widget
>  in any way, the mouse pointer will cease to show the double-arrow
>  shape on the window borders - the pointer remains an arrowhead.
>  You can still resize the window and the cursor does change to
>  a double-arrow when you press the left button.
>
> My workaround for this was to add the following lines of code in my
> application:
>
>        def onleave(self):
>           QtGui.QApplication.restoreOverrideCursor()
>
>        self.fig.canvas.mpl_connect('figure_leave_event',  onleave)
>
> I guessed these lines by studying the matplotlib code.  Probably they
> need to go somewhere inside the Matplotlib class definitions.
>
> I hope this helps developers to correct this problem.  My application
> code is medium-large and I didn't try to build a smaller example.  The
> mysterious 3-line workaround solves my problem for the moment.
> Perhaps it will help another PyQt and Matplotlib user and perhaps
> urge developers to fix the problem in the Matplotlib core.

Now that you mention it, I have seen similar behavior. Thanks for the
report, I'll look into it.

Darren

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2D polar surface plot

2010-06-18 Thread Friedrich Romstedt
2010/6/16 Michael Droettboom :
> pcolor runs directly on polar plots just fine.  No need to convert polar to
> cartesian outside of matplotlib.

It's true, but at the expense of pretty much time, since the arcs must
be rendered properly.  If your data is dense enough in r and phi, a
handmade conversion would probably gain much speedup.  Of course you
loose then also the nice polar diagram axes ... I tried this once in
polar with pixel-dense data (in a 400x400 px figure) and it takes
really forever.

I don't know if the output of the fast versions of pcolor is properly
rendered in polar axes?

Friedrich

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlab freezes with a graph and toolbar

2010-06-18 Thread Friedrich Romstedt
2010/6/15 Eliot Glairon :
> class simpleapp_tk(Tkinter.Tk):#initialize
>    def __init__(self,parent):
>        Tkinter.Tk.__init__(self,parent)
>        self.grid()

It sounds a bit odd to me to attemt to .grid() a Tk instance ... The
Tkinter.Tk() instance is the toplevel application window.  You do not
have to grid it.

Also, I don't know what the *parent* argument means to to
Tkinter.Tk.__init__().  Try to leave the parent argument alone, and
try to remove the .grid().

Friedrich

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Demo does not work on Snow Leopard

2010-06-18 Thread Friedrich Romstedt
2010/6/17 Hana Sevcikova :
> I installed matplotlib-0.99.3-py2.6-macosx10.6.dmg on MacOS X 10.6.3,
> python 2.6.5. But I get an error when running the histogram example from
> http://matplotlib.sourceforge.net/examples/api/histogram_demo.html

Have you compiled Python yourself?  I'm asking because Python 2.6.5
from Python.org is maybe linked against another Tcl/Tk than it links
to when you compile yourself.  (I guess the matplotlib._tkagg module
does some patchy things.)

Friedrich

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting dates and dtypes

2010-06-18 Thread Bill Eaton

I came up with a partial solution for my problem. I found an example from
Sandro Tosi (http://www.packtpub.com/article/advanced-matplotlib-part2. I
think I may have to buy his book.) using datutil.parser. I'm not sure why a
straight numpy.load doesn't work.

Code was:
 > I tried to import my own data. It looks like 
 >2005-03-04,0.923115796
 >2005-03-05,0.915828724
 >2005-03-06,0.442521474
 >2005-03-07,0.997096213
 >2005-03-08,0.867752118
 > And to import, I use recarray
 >   myarray = np.loadtxt(fullfile, dtype=[('date', '|O4'), ('ydata',
 > 'float')], delimiter = ',')
 >   rx = myarray.view(np.recarray)
 > 
 > Data imports fine. But when I go to plot, I get the following error
 >   ValueError: setting an array element with a sequence.
 >   WARNING: Failure executing file: 

If I modify to:

  import datutil

  myarray = np.loadtxt(fullfile, dtype=[('datestring', '|S22'), ('ydata',
'float')], delimiter = ',')
  dates = [dateutil.parser.parse(s) for s in myarray['datestring']]

Now I can plot with
  plt.plot(dates, myarray['ydata']

Bill Eaton






--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting dates and dtypes

2010-06-18 Thread Ryan May
On Thu, Jun 17, 2010 at 11:39 AM, Bill Eaton  wrote:
> I'm struggling to figure out how to format my data so that I can use dates
> as x-data.

> I tried to import my own data. It looks like
>   2005-03-04,0.923115796
>   2005-03-05,0.915828724
>   2005-03-06,0.442521474
>   2005-03-07,0.997096213
>   2005-03-08,0.867752118
> And to import, I use recarray
>  myarray = np.loadtxt(fullfile, dtype=[('date', '|O4'), ('ydata',
> 'float')], delimiter = ',')
>  rx = myarray.view(np.recarray)
>
> Data imports fine. But when I go to plot, I get the following error
>  ValueError: setting an array element with a sequence.
>  WARNING: Failure executing file: 

You need to give np.loadtxt a converter so that it converts that first
column of strings into datetime objects:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import dates
from datetime import datetime
from StringIO import StringIO

s='''
  2005-03-04,0.923115796
  2005-03-05,0.915828724
  2005-03-06,0.442521474
  2005-03-07,0.997096213
  2005-03-08,0.867752118'''

dateparser = lambda s: datetime.strptime(s, '%Y-%m-%d')
dt = np.dtype([('date', np.object),('ydata', np.float)])
d = np.loadtxt(StringIO(s), dtype=dt, converters={0:dateparser}, delimiter=',')
plt.plot(d['date'], d['ydata'])
plt.gca().xaxis.set_major_locator(dates.DayLocator())
plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%Y/%m/%d'))
plt.show()

Personally, I find it much easier to work with python datetime objects
than any other form. You can

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting dates and dtypes

2010-06-18 Thread Eric Firing
On 06/18/2010 07:31 AM, Ryan May wrote:
> On Thu, Jun 17, 2010 at 11:39 AM, Bill Eaton  wrote:
>> I'm struggling to figure out how to format my data so that I can use dates
>> as x-data.
> 
>> I tried to import my own data. It looks like
>>2005-03-04,0.923115796
>>2005-03-05,0.915828724
>>2005-03-06,0.442521474
>>2005-03-07,0.997096213
>>2005-03-08,0.867752118


Try matplotlib's mlab.csv2rec.  It has a lot of magic built-in, 
including automatic date recognition.

Eric


>> And to import, I use recarray
>>   myarray = np.loadtxt(fullfile, dtype=[('date', '|O4'), ('ydata',
>> 'float')], delimiter = ',')
>>   rx = myarray.view(np.recarray)
>>
>> Data imports fine. But when I go to plot, I get the following error
>>   ValueError: setting an array element with a sequence.
>>   WARNING: Failure executing file:
>
> You need to give np.loadtxt a converter so that it converts that first
> column of strings into datetime objects:
>
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib import dates
> from datetime import datetime
> from StringIO import StringIO
>
> s='''
>2005-03-04,0.923115796
>2005-03-05,0.915828724
>2005-03-06,0.442521474
>2005-03-07,0.997096213
>2005-03-08,0.867752118'''
>
> dateparser = lambda s: datetime.strptime(s, '%Y-%m-%d')
> dt = np.dtype([('date', np.object),('ydata', np.float)])
> d = np.loadtxt(StringIO(s), dtype=dt, converters={0:dateparser}, 
> delimiter=',')
> plt.plot(d['date'], d['ydata'])
> plt.gca().xaxis.set_major_locator(dates.DayLocator())
> plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%Y/%m/%d'))
> plt.show()
>
> Personally, I find it much easier to work with python datetime objects
> than any other form. You can
>
> Ryan
>


--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Demo does not work on Snow Leopard

2010-06-18 Thread Hana Sevcikova
I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. 
(Sorry, I should have mentioned that before.)

Hana

On 6/18/10 7:11 AM, Friedrich Romstedt wrote:
> 2010/6/17 Hana Sevcikova:
>
>> I installed matplotlib-0.99.3-py2.6-macosx10.6.dmg on MacOS X 10.6.3,
>> python 2.6.5. But I get an error when running the histogram example from
>> http://matplotlib.sourceforge.net/examples/api/histogram_demo.html
>>  
> Have you compiled Python yourself?  I'm asking because Python 2.6.5
> from Python.org is maybe linked against another Tcl/Tk than it links
> to when you compile yourself.  (I guess the matplotlib._tkagg module
> does some patchy things.)
>
> Friedrich
>


--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Installation for MAC OS 10.5

2010-06-18 Thread R. Padraic Springuel
Has anyone created installation package for matplotlib 0.99.3 that is 
compatible with MAC OS 10.5 and Python 2.6?  One one on the download 
site for MAC OS 10.6 doesn't work on my system (presumably because I'm 
still working with Leopard because everything else is up to date).
-- 

R. Padraic Springuel
Research Assistant
Department of Physics and Astronomy
University of Maine
Bennett 309
Office Hours: By Appointment Only

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Demo does not work on Snow Leopard

2010-06-18 Thread Friedrich Romstedt
2010/6/18 Hana Sevcikova :
> I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. (Sorry,
> I should have mentioned that before.)

Hmm, could you please run:

otool -L 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
otool -L 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/_tkagg.so

and post the output (copy to clipboard with | pbcopy)

Friedrich

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Demo does not work on Snow Leopard

2010-06-18 Thread Hana Sevcikova

# otool -L 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so:
 /Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (compatibility 
version 8.4.0, current version 8.4.19)
 /Library/Frameworks/Tk.framework/Versions/8.4/Tk (compatibility 
version 8.4.0, current version 8.4.19)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 88.3.10)

I needed to modify the path in the second command, since matplotlib was 
installed into /Library/Python/2.6/site-packages. Could that be the 
issue? Anyway, here is the output:

# otool -L /Library/Python/2.6/site-packages/matplotlib/backends/_tkagg.so
/Library/Python/2.6/site-packages/matplotlib/backends/_tkagg.so:
 /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current 
version 7.9.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 125.0.1)
 /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 
1.2.3)
 /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl 
(compatibility version 8.5.0, current version 8.5.7)
 /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk 
(compatibility version 8.5.0, current version 8.5.7)

I see there are some compatibility issues. What would be the best way to 
deal with it?

Thanks,
Hana

On 6/18/10 2:07 PM, Friedrich Romstedt wrote:
> 2010/6/18 Hana Sevcikova:
>
>> I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. (Sorry,
>> I should have mentioned that before.)
>>  
> Hmm, could you please run:
>
> otool -L 
> /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
> otool -L 
> /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/_tkagg.so
>
> and post the output (copy to clipboard with | pbcopy)
>
> Friedrich
>


--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users