[matplotlib-devel] Updates to transforms.py

2011-03-02 Thread Benjamin Root
Hello all,

As part of my process for updating mplot3d, I realized that transforms.py
needed to be revamped first.  In many places in transforms.py, there were
unnecessary 2-D assumptions that needed to be removed or generalized.  I
have started this effort here:

https://github.com/WeatherGod/matplotlib/compare/master...test%2Fmplot3d-ndtransforms

I still have more to do in this file, but this version passes the unit
tests, and I would welcome any comments and thoughts.  Part of the efforts
have been trying to shoehorn n-d positional arguments into various function
signatures.  For example:

def foo(self, x, y) :
pass

becomes

def foo(self, x, y, *args) :
pass

In some places, like shrunk_to_aspect(), I decided that I would just allow
the operation to continue for just the first two dims.  In other places, I
tried to allow for mis-matches of dimensions with reasonable defaults (e.g.,
shrunk()).

My main problem in pushing forward right now is that there are functions
that have signatures like the following:

def foo(self, x, y, ignorex=True, ignorey=True) :
pass

Unfortunately, it is not until py3k that we can utilize keyword-only
arguments that would allow us to place a positional argument in between the
*y* and the *ignorex*, and we would run the risk of breaking function calls
like "foo(x, y, False, False)" which is valid now.  Therefore, I are going
to need to introduce some new functions to transforms.py that would allow
n-d arguments and deprecate the problematic functions.

Anyway, this is my progress so far.  I would welcome any input, thoughts,
concerns and such.

Thanks,
Ben Root
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Simple animation test

2011-03-02 Thread Brian Granger
Hi,

I am trying to do a simple animation examples similar to the one here:

http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc

But it does not work.  I have tried with different backends, plain
python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
from EPD.  I have used this approach in the past, but no luck this
time.  If I add a show() early on, the first plot shows OK, but it
sits and waits until I close the plot window before moving on.  Any
ideas?

Cheers,

Brian

-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgran...@calpoly.edu
elliso...@gmail.com

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread John Hunter
On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger  wrote:
> Hi,
>
> I am trying to do a simple animation examples similar to the one here:
>
> http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
>
> But it does not work.  I have tried with different backends, plain
> python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
> from EPD.  I have used this approach in the past, but no luck this
> time.  If I add a show() early on, the first plot shows OK, but it
> sits and waits until I close the plot window before moving on.  Any
> ideas?

If you are running mpl from the development tree on github, I suggest
you use the new animations API, which hides much of the complexity.
See

  https://github.com/matplotlib/matplotlib/tree/master/examples/animation

If you are running a released mpl, you can simply drop the
animation.py file into your PYTHONPATH and use it directly

  
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py

Hope this helps,
JDH

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Benjamin Root
On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger  wrote:

> Hi,
>
> I am trying to do a simple animation examples similar to the one here:
>
>
> http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
>
> But it does not work.  I have tried with different backends, plain
> python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
> from EPD.  I have used this approach in the past, but no luck this
> time.  If I add a show() early on, the first plot shows OK, but it
> sits and waits until I close the plot window before moving on.  Any
> ideas?
>
> Cheers,
>
> Brian
>
>
Animations can be a very fickle thing in matplotlib.  Everything has to be
perfect for it to work properly.  Are you able to run that first example on
that page?  Can you include a self-contained version of your code that
reproduces your problem?

Ben Root
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Problems with new PyQt4 API

2011-03-02 Thread Martin Teichmann
Hi list,

I'm using matplotlib as a library, in a program using the
new APIs of PyQt4, which will be the normal APIs for
Python 3. Unfortunately, the matplotlib Qt4 backend is
not compatible with this new API.

The problems are easy to fix: first QFileDialog.getSaveFileName
has changed, and is to be replaced with
QFileDialog.getSaveFileNameAndFilter, for example with the following
patch:

---
--- backend_qt4.py  2011-03-02 16:17:19.526831397 +0100
+++ backend_qt4_orig.py 2011-03-02 16:16:38.257797767 +0100
@@ -395,9 +395,8 @@
 filters.append(filter)
 filters = ';;'.join(filters)

-fname, _ = QtGui.QFileDialog.getSaveFileNameAndFilter(
-self, "Choose a filename to save to", start, filters,
-selectedFilter)
+fname = QtGui.QFileDialog.getSaveFileName(
+self, "Choose a filename to save to", start, filters,
selectedFilter)
 if fname:
 try:
 self.canvas.print_figure( unicode(fname) )
---

secondly, QString is used in the new formlayout, wich can be avoided
using yet another patch, that I actually once filed as Path #3081405
in the matplotlib patch tracker.

---
--- formlayout.py   2010-10-05 11:45:01.0 +0200
+++ formlayout.py-orig  2010-10-01 12:28:34.0 +0200
@@ -56,7 +56,8 @@
  QPixmap, QTabWidget, QApplication, QStackedWidget,
  QDateEdit, QDateTimeEdit, QFont, QFontComboBox,
  QFontDatabase, QGridLayout)
-from PyQt4.QtCore import Qt, SIGNAL, SLOT, QSize, pyqtSignature, pyqtProperty
+from PyQt4.QtCore import (Qt, SIGNAL, SLOT, QSize, QString,
+  pyqtSignature, pyqtProperty)
 from datetime import date


@@ -101,7 +102,10 @@
 Avoid warning from Qt when an invalid QColor is instantiated
 """
 color = QColor()
-text = unicode(text)
+if isinstance(text, QString):
+text = str(text)
+if not isinstance(text, (unicode, str)):
+return color
 if text.startswith('#') and len(text)==7:
 correct = '#0123456789abcdef'
 for char in text:
---

Greetings

Martin

-- 
Max-Born-Institut
Max-Born-Straße 2a
12489 Berlin
+49 30 6392 1234

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Brian Granger
Is the old method (just using draw/set_xdata, etc.) not supported?  I
am working with a student and I want to keep is dead simple.

Brian

On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root  wrote:
>
>
> On Wed, Mar 2, 2011 at 7:44 AM, John Hunter  wrote:
>>
>> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger 
>> wrote:
>> > Hi,
>> >
>> > I am trying to do a simple animation examples similar to the one here:
>> >
>> >
>> > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
>> >
>> > But it does not work.  I have tried with different backends, plain
>> > python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
>> > from EPD.  I have used this approach in the past, but no luck this
>> > time.  If I add a show() early on, the first plot shows OK, but it
>> > sits and waits until I close the plot window before moving on.  Any
>> > ideas?
>>
>> If you are running mpl from the development tree on github, I suggest
>> you use the new animations API, which hides much of the complexity.
>> See
>>
>>  https://github.com/matplotlib/matplotlib/tree/master/examples/animation
>>
>> If you are running a released mpl, you can simply drop the
>> animation.py file into your PYTHONPATH and use it directly
>>
>>
>>  https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py
>>
>> Hope this helps,
>> JDH
>>
>
> I don't think that is necessarily true.  If I remember correctly, Ryan May
> introduced some other API changes (I think they made it to the 1.0.x branch)
> in order to facilitate his animations.
>
> Ben Root
>
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgran...@calpoly.edu
elliso...@gmail.com

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] pick_event problems

2011-03-02 Thread James Kitchen
Hello all,

I've been working on some interactive graphs and have run into several problems 
with the pick_event feature:
(1) If a Figure Legend is made draggable() and then dropped onto an 
AxesSubplot, 
it can no longer be dragged
(2) Any lines associated with the left axis of a twinx() subplot are unable to 
be picked
(3) Hidden lines can be picked (seems like an undesirable feature).  Try 
picking 
on the top subplot at y=1 for a hidden line.

I know #2 has http://old.nabble.com/onpick-on-a-2-y-plot-%28-via-twinx%28%29-%29-seems-to-only-allow-picking-of-second-axes%27s-artists-td25049128.html";>caused
 problems for others, with less than elegant solutions given.

Here's the code showing what is currently broken (as of v1.0.0):

#!/usr/bin/env python
import matplotlib as mpl
import pylab

# <-- Insert code to fix problem here

def on_pick(event):
if isinstance(event.artist, mpl.legend.Legend):
print 'Picked Legend'
else:
print 'Picked', event.artist.get_label(), event.ind

fig = pylab.figure()
ax = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax3 = ax2.twinx()
# Top subplot
ax.plot(range(10), range(10), c='r', marker='^', picker=5, label='Ramp')
line, = ax.plot(range(10), [1]*10, c='k', marker='o', picker=5, label='Hidden')
line.set_visible(False)
# Bottom subplot
legn_handles = []
legn_labels = []
line = ax2.plot(range(10), [1,3,1,3,0,3,1,3,1,3], c='b', marker='o', picker=5, 
label='Teeth')
legn_handles.append(line)
legn_labels.append('Teeth')
ax2.set_ylim(0, 4)
ax2.set_ylabel('Left side', color='b')
line = ax3.plot(range(10), [1,1,1,1,4,4,4,4,4,4], c='m', marker='.', picker=5, 
label='Shelf')
legn_handles.append(line)
legn_labels.append('Shelf')
ax3.set_ylim(0, 5)
ax3.set_ylabel('Right side', color='m')
# Subplot Legend for top plot
legn = ax.legend()
legn.draggable()
# Figure Legend
legn = fig.legend(legn_handles, legn_labels, 'lower right')
legn.draggable()
fig.canvas.mpl_connect('pick_event', on_pick)
pylab.show()
# 




I've found a decent workaround, but it involves some very fundamental  changes 
to the way picking is resolved in the Figure and Axes classes.  If you add the 
following code to the spot indicated for the fix, everything works correctly.

# Fix for pick_event problems
def axes_pick(self, *args):
if len(args)>1:
raise DeprecationWarning('New pick API implemented -- '
 'see API_CHANGES in the src distribution')
mouseevent = args[0]
if not self.in_axes(mouseevent):
return
for a in self.get_children():
if not a.get_visible():
continue
a.pick(mouseevent)
mpl.axes.Axes.pick = axes_pick

def figure_pick(self, mouseevent):
for a in self.get_children():
if not a.get_visible():
continue
a.pick(mouseevent)
mpl.figure.Figure.pick = figure_pick


To compare the differences, you need to look at the artist.Artist.pick() 
method.  It only calls pick() for children whose axes==mouseevent.inaxes or 
when 
inaxes is None (to handle the Legend).  But this fails when the Legend is 
dragged over a Subplot (inaxes no longer None), causing bug #1.  Also, 
mouseevent.inaxes only contains a single axes instance, which causes a failure 
for overlapping twinx() axes, hence bug #2.  And of course there is no check 
for 
hidden artists (#3).

My change calls pick() for every child of the Figure or Subplot, but then has 
the Subplot check whether the mouseevent is in its own axes space.  This seems 
to fix all the problems, but could potentially cause new bugs.  Any thoughts?  
I'm new to the mailing list, so I'm not sure how patches get applied and how 
much testing needs to be done for a change like this.

Thanks,
Jim



  

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Benjamin Root
On Wed, Mar 2, 2011 at 7:44 AM, John Hunter  wrote:

> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger 
> wrote:
> > Hi,
> >
> > I am trying to do a simple animation examples similar to the one here:
> >
> >
> http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
> >
> > But it does not work.  I have tried with different backends, plain
> > python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
> > from EPD.  I have used this approach in the past, but no luck this
> > time.  If I add a show() early on, the first plot shows OK, but it
> > sits and waits until I close the plot window before moving on.  Any
> > ideas?
>
> If you are running mpl from the development tree on github, I suggest
> you use the new animations API, which hides much of the complexity.
> See
>
>  https://github.com/matplotlib/matplotlib/tree/master/examples/animation
>
> If you are running a released mpl, you can simply drop the
> animation.py file into your PYTHONPATH and use it directly
>
>
> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py
>
> Hope this helps,
> JDH
>
>
I don't think that is necessarily true.  If I remember correctly, Ryan May
introduced some other API changes (I think they made it to the 1.0.x branch)
in order to facilitate his animations.

Ben Root
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Problems with new PyQt4 API

2011-03-02 Thread Benjamin Root
On Wed, Mar 2, 2011 at 9:26 AM, Martin Teichmann wrote:

> Hi list,
>
> I'm using matplotlib as a library, in a program using the
> new APIs of PyQt4, which will be the normal APIs for
> Python 3. Unfortunately, the matplotlib Qt4 backend is
> not compatible with this new API.
>
> The problems are easy to fix: first QFileDialog.getSaveFileName
> has changed, and is to be replaced with
> QFileDialog.getSaveFileNameAndFilter, for example with the following
> patch:
>
>
> ---
> --- backend_qt4.py  2011-03-02 16:17:19.526831397 +0100
> +++ backend_qt4_orig.py 2011-03-02 16:16:38.257797767 +0100
> @@ -395,9 +395,8 @@
> filters.append(filter)
> filters = ';;'.join(filters)
>
> -fname, _ = QtGui.QFileDialog.getSaveFileNameAndFilter(
> -self, "Choose a filename to save to", start, filters,
> -selectedFilter)
> +fname = QtGui.QFileDialog.getSaveFileName(
> +self, "Choose a filename to save to", start, filters,
> selectedFilter)
> if fname:
> try:
> self.canvas.print_figure( unicode(fname) )
>
> ---
>
> secondly, QString is used in the new formlayout, wich can be avoided
> using yet another patch, that I actually once filed as Path #3081405
> in the matplotlib patch tracker.
>
>
> ---
> --- formlayout.py   2010-10-05 11:45:01.0 +0200
> +++ formlayout.py-orig  2010-10-01 12:28:34.0 +0200
> @@ -56,7 +56,8 @@
>  QPixmap, QTabWidget, QApplication, QStackedWidget,
>  QDateEdit, QDateTimeEdit, QFont, QFontComboBox,
>  QFontDatabase, QGridLayout)
> -from PyQt4.QtCore import Qt, SIGNAL, SLOT, QSize, pyqtSignature,
> pyqtProperty
> +from PyQt4.QtCore import (Qt, SIGNAL, SLOT, QSize, QString,
> +  pyqtSignature, pyqtProperty)
>  from datetime import date
>
>
> @@ -101,7 +102,10 @@
> Avoid warning from Qt when an invalid QColor is instantiated
> """
> color = QColor()
> -text = unicode(text)
> +if isinstance(text, QString):
> +text = str(text)
> +if not isinstance(text, (unicode, str)):
> +return color
> if text.startswith('#') and len(text)==7:
> correct = '#0123456789abcdef'
> for char in text:
>
> ---
>
> Greetings
>
> Martin
>
>
Martin,

Thank you for letting us know about continuing issues with PyQT4.  First, I
think your patches are "backwards", per se.  Can you double-check that they
are what you mean?  Also, which version of matplotlib did you patch
against?  I know that we recently made a fix involving QString:

https://github.com/matplotlib/matplotlib/commit/fa82c5adcc1493ec705728e4beb806cb4c84579f

I see we probably still need to fix the backend, but is everything else in
order?

Ben Root
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Problems with new PyQt4 API

2011-03-02 Thread Darren Dale
On Wed, Mar 2, 2011 at 10:26 AM, Martin Teichmann
 wrote:
> Hi list,
>
> I'm using matplotlib as a library, in a program using the
> new APIs of PyQt4, which will be the normal APIs for
> Python 3. Unfortunately, the matplotlib Qt4 backend is
> not compatible with this new API.

This really doesn't belong on the PyQt4 mailing list. Please post to
the matplotlib user or developer list.

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Problems with new PyQt4 API

2011-03-02 Thread Darren Dale
On Wed, Mar 2, 2011 at 4:26 PM, Darren Dale  wrote:
> On Wed, Mar 2, 2011 at 10:26 AM, Martin Teichmann
>  wrote:
>> Hi list,
>>
>> I'm using matplotlib as a library, in a program using the
>> new APIs of PyQt4, which will be the normal APIs for
>> Python 3. Unfortunately, the matplotlib Qt4 backend is
>> not compatible with this new API.
>
> This really doesn't belong on the PyQt4 mailing list. Please post to
> the matplotlib user or developer list.

My apologies. I thought I saw this posted to the pyqt4 mailing list.
Trying to do too many things at once.

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Benjamin Root
On Wed, Mar 2, 2011 at 12:43 PM, Brian Granger  wrote:

> Is the old method (just using draw/set_xdata, etc.) not supported?  I
> am working with a student and I want to keep is dead simple.
>
> Brian
>
>
Those functions are still supported.  I can run the example on that page
without issues using the development version of mpl, GTKAgg, and python
2.6.  There might be some other possibilities to consider.  For example, if
you are working in the pylab mode and you have multiple figures and/or axes,
the draw() command might be going to the wrong figure because draw()
operates on whichever figure would be returned by gcf() (I believe).

Ben Root
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Ryan May
On Wed, Mar 2, 2011 at 12:43 PM, Brian Granger  wrote:
> Is the old method (just using draw/set_xdata, etc.) not supported?  I
> am working with a student and I want to keep is dead simple.

The old method is subject to the problems you're encountering now
because you're working outside the GUI's event loop. The new method
was created to be "dead simple" and yet work reliably. If there's some
kind of unintuitive/hard part of the new animation API, I'd love to
know about it.

Ryan

>
> Brian
>
> On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root  wrote:
>>
>>
>> On Wed, Mar 2, 2011 at 7:44 AM, John Hunter  wrote:
>>>
>>> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger 
>>> wrote:
>>> > Hi,
>>> >
>>> > I am trying to do a simple animation examples similar to the one here:
>>> >
>>> >
>>> > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
>>> >
>>> > But it does not work.  I have tried with different backends, plain
>>> > python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
>>> > from EPD.  I have used this approach in the past, but no luck this
>>> > time.  If I add a show() early on, the first plot shows OK, but it
>>> > sits and waits until I close the plot window before moving on.  Any
>>> > ideas?
>>>
>>> If you are running mpl from the development tree on github, I suggest
>>> you use the new animations API, which hides much of the complexity.
>>> See
>>>
>>>  https://github.com/matplotlib/matplotlib/tree/master/examples/animation
>>>
>>> If you are running a released mpl, you can simply drop the
>>> animation.py file into your PYTHONPATH and use it directly
>>>
>>>
>>>  https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py
>>>
>>> Hope this helps,
>>> JDH
>>>
>>
>> I don't think that is necessarily true.  If I remember correctly, Ryan May
>> introduced some other API changes (I think they made it to the 1.0.x branch)
>> in order to facilitate his animations.
>>
>> Ben Root
>>
>>
>
>
>
> --
> Brian E. Granger, Ph.D.
> Assistant Professor of Physics
> Cal Poly State University, San Luis Obispo
> bgran...@calpoly.edu
> elliso...@gmail.com
>
> --
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
> generated by your applications, servers and devices whether physical, virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>



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

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Brian Granger
>> Is the old method (just using draw/set_xdata, etc.) not supported?  I
>> am working with a student and I want to keep is dead simple.
>
> The old method is subject to the problems you're encountering now
> because you're working outside the GUI's event loop. The new method
> was created to be "dead simple" and yet work reliably. If there's some
> kind of unintuitive/hard part of the new animation API, I'd love to
> know about it.

The main issue I have is that I am working with undergraduate students
who have no experience installing things from scratch.  In this
context I am stuck with whatever is in EPD.  Currently EPD is at
1.0.1, which does not have animation.  Will this file "just work" with
1.0.1 or 0.99.3?  I don't have any aversion to using animation.py, I
just need to be able to use it within a stock recent EPD.

Cheers,

Brian

> Ryan
>
>>
>> Brian
>>
>> On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root  wrote:
>>>
>>>
>>> On Wed, Mar 2, 2011 at 7:44 AM, John Hunter  wrote:

 On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger 
 wrote:
 > Hi,
 >
 > I am trying to do a simple animation examples similar to the one here:
 >
 >
 > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc
 >
 > But it does not work.  I have tried with different backends, plain
 > python, within ipython.  I am using ipython 0.10 and matplotlib 0.99.3
 > from EPD.  I have used this approach in the past, but no luck this
 > time.  If I add a show() early on, the first plot shows OK, but it
 > sits and waits until I close the plot window before moving on.  Any
 > ideas?

 If you are running mpl from the development tree on github, I suggest
 you use the new animations API, which hides much of the complexity.
 See

  https://github.com/matplotlib/matplotlib/tree/master/examples/animation

 If you are running a released mpl, you can simply drop the
 animation.py file into your PYTHONPATH and use it directly


  https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py

 Hope this helps,
 JDH

>>>
>>> I don't think that is necessarily true.  If I remember correctly, Ryan May
>>> introduced some other API changes (I think they made it to the 1.0.x branch)
>>> in order to facilitate his animations.
>>>
>>> Ben Root
>>>
>>>
>>
>>
>>
>> --
>> Brian E. Granger, Ph.D.
>> Assistant Professor of Physics
>> Cal Poly State University, San Luis Obispo
>> bgran...@calpoly.edu
>> elliso...@gmail.com
>>
>> --
>> Free Software Download: Index, Search & Analyze Logs and other IT data in
>> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
>> generated by your applications, servers and devices whether physical, virtual
>> or in the cloud. Deliver compliance at lower cost and gain new business
>> insights. http://p.sf.net/sfu/splunk-dev2dev
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>
>
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgran...@calpoly.edu
elliso...@gmail.com

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread John Hunter
On Wed, Mar 2, 2011 at 4:43 PM, Brian Granger  The main issue I have is that I am working with undergraduate students
> who have no experience installing things from scratch.  In this
> context I am stuck with whatever is in EPD.  Currently EPD is at
> 1.0.1, which does not have animation.  Will this file "just work" with
> 1.0.1 or 0.99.3?  I don't have any aversion to using animation.py, I
> just need to be able to use it within a stock recent EPD.

With EPD and mpl 1.0.1, the new API should work if you drop
animation.py into your site-packages, eg as mpl_animation.py,and
import it like

  import mpl_animation as animation

Then later they can just change this to

  import matplotlib.animation as animation

Let us know if you have any troubles with this approach.

I've attached a double pendulum example which is fun, and illustrates
how to animate multiple objects, a line instance for the pendulum and
a text instance for the time counter.

JDH


double_pendulum_animated.py
Description: Binary data
--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev ___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Ryan May
On Wed, Mar 2, 2011 at 4:50 PM, John Hunter  wrote:
> On Wed, Mar 2, 2011 at 4:43 PM, Brian Granger > The main issue I have is that I am working with undergraduate students
>> who have no experience installing things from scratch.  In this
>> context I am stuck with whatever is in EPD.  Currently EPD is at
>> 1.0.1, which does not have animation.  Will this file "just work" with
>> 1.0.1 or 0.99.3?  I don't have any aversion to using animation.py, I
>> just need to be able to use it within a stock recent EPD.
>
> With EPD and mpl 1.0.1, the new API should work if you drop
> animation.py into your site-packages, eg as mpl_animation.py,and
> import it like
>
>  import mpl_animation as animation
>
> Then later they can just change this to
>
>  import matplotlib.animation as animation
>
> Let us know if you have any troubles with this approach.
>
> I've attached a double pendulum example which is fun, and illustrates
> how to animate multiple objects, a line instance for the pendulum and
> a text instance for the time counter.

I trust you're going to check in that completely awesome example.

Brian, if you're still adverse to using an external module (I
understand), 1.0.1 does have the new timer infrastructure that will
work with the event loop properly. Here's your example converted to
taht:

from pylab import *

def update_line(line):
line.set_ydata(sin(x+line.counter/10.0))  # update the data
line.counter += 1
draw()
if line.counter > 200:
return False

x = arange(0,2*pi,0.01)# x-array
line, = plot(x,sin(x))
line.counter = 0 # Store the counter on the line object

# Get the current figure and get it to create a new timer.
fig = gcf()
timer = fig.canvas.new_timer(interval=50)
timer.add_callback(update_line, line)
timer.start()
show()

Ryan

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

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Simple animation test

2011-03-02 Thread Fernando Perez
On Wed, Mar 2, 2011 at 3:00 PM, Ryan May  wrote:
> I trust you're going to check in that completely awesome example.

BTW, that  completely awesome example was just demoed in front of a
standing-room only audience at the SIAM CSE 11 meeting :)  The
matplotlib talk (delivered by yours truly b/c John couldn't make it)
was very well received, the interest in Python here is remarkable.

Cheers,

f

--
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel