[Matplotlib-users] Event handling, API programming

2008-10-26 Thread Adam
Hi, I'm trying to make myself a set of widgets for the first time.
 I've gotten to the point that I can draw rectangles and lines and make
 them do the right things when re-drawing figures, zooming, etc., but
 I'm still a little lost on some points, and I haven't found any really
 good documentation.


So, first question: Where should I go for documentation first?


I've been using examples, e.g. widgets.py, and the pygtk event
 handling page, http://www.pygtk.org/pygtk2tutorial/sec-EventHandling.html.
 This page was a useful explanation of the stuff in widgets.py:
 http://www.nabble.com/some-API-documentation-td16204232.html.


Second question:  I have two subplots of different data with the same
 dimensions.  I'd like to zoom in to the same region on both figures
 when I use zoom-to-box on either one.  How can I do this?  (I'm using
 tkAgg)
 Thanks,
 Adam

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why is wrapper module called "pylab" ?

2008-10-26 Thread Eric Firing
Ryan May wrote:
> They're the same plotting interface, just different names.  Pylab pulls 
> in a few extra functions that aren't specific to plotting, but aid in 
> providing matlab-alike functionality.  To use matplotlib.pyplot instead 
> of pylab for any of the examples, just replace lines of:
> 
> import pylab
> 
> with:
> 
> import matplotlib.pyplot

Not quite--the above, taken literally, will not actually work.

To elaborate: pyplot provides a matlab-style state-machine interface to 
the underlying object-oriented interface in matplotlib.  Pylab lumps 
pyplot together with numpy in a single namespace, making that namespace 
(or environment) even more matlab-like, particularly if one uses the 
ipython shell with the "-pylab" option, which imports everything from pylab.

Regarding matplotlib examples: we have been gradually converting them 
from pure matlab-style, using "from pylab import *", to a preferred 
style in which pyplot is used for some convenience functions, either 
pyplot or the object-oriented style is used for the remainder of the 
plotting code, and numpy is used explicitly for numeric array operations.

In this preferred style, the imports at the top are:

import matplotlib.pyplot as plt
import numpy as np

Then one calls, for example, np.arange, np.zeros, np.pi, plt.figure, 
plt.plot, plt.show, etc.

Example, pure matlab-style:

from pylab import *
x = arange(0, 10, 0.2)
y = sin(x)
plot(x, y)
show()

Now in preferred style, but still using pyplot interface:

import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.2)
y = np.sin(x)
plt.plot(x, y)
plt.show()

And using pyplot convenience functions, but object-orientation for the rest:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.2)
y = np.sin(x)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
plt.show()

So, why do all the extra typing required as one moves away from the pure 
matlab-style?  For very simple things like this example, the only 
advantage is educational: the wordier styles are more explicit, more 
clear as to where things come from and what is going on.  For more 
complicated applications, the explicitness and clarity become 
increasingly valuable, and the richer and more complete object-oriented 
interface will likely make the program easier to write and maintain.

Eric



> 
> Ryan
> 
> On Sun, Oct 26, 2008 at 11:29 AM, <[EMAIL PROTECTED] 
> > wrote:
> 
> On Sun, Oct 26, 2008 at 11:51:48AM -0400, Charlie Moad wrote:
>  > The matplotlib.pyplot is favored over the pylab module now.
> 
> Thanks!  I find your comment very interesting.  As I have negligible
> experience
> with Matlab, I'd love to use matplotlib.pyplot.
> 
> The problem is all the docs use pylab right?  Where find
> matplotlib.pyplot
> examples?
> 
> Chris
> 
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> 
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> 
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> 
> 
> -- 
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
> 
> 
> 
> 
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Re: [Matplotlib-users] Why is wrapper module called "pylab" ?

2008-10-26 Thread Ryan May
They're the same plotting interface, just different names.  Pylab pulls in a
few extra functions that aren't specific to plotting, but aid in providing
matlab-alike functionality.  To use matplotlib.pyplot instead of pylab for
any of the examples, just replace lines of:

import pylab

with:

import matplotlib.pyplot

Ryan

On Sun, Oct 26, 2008 at 11:29 AM, <[EMAIL PROTECTED]> wrote:

> On Sun, Oct 26, 2008 at 11:51:48AM -0400, Charlie Moad wrote:
> > The matplotlib.pyplot is favored over the pylab module now.
>
> Thanks!  I find your comment very interesting.  As I have negligible
> experience
> with Matlab, I'd love to use matplotlib.pyplot.
>
> The problem is all the docs use pylab right?  Where find matplotlib.pyplot
> examples?
>
> Chris
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] clabel

2008-10-26 Thread David Arnold
Eric et al,

Very nice. However, I am running the latest Enthought EPD on Mac OS X  
10.4.11 and I get this:

In [6]: clabel(cs,inline=1,fontsize=10,manual=True)
Select label locations manually using first mouse button.
End manual selection with second mouse button.
/Library/Frameworks/Python.framework/Versions/4.0.30002/lib/python2.5/ 
site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/ 
matplotlib/backend_bases.py:1448: DeprecationWarning: Using default  
event loop until function specific to this GUI is implemented
   warnings.warn(str,DeprecationWarning)

It works, adding labels whenever I click with my mouse, but I cannot  
end labeling. I've tried various combinations with the mouse (ctrl 
+click, option+click, command+click) and keyboard (Enter), to no avail.

Has anyone tried this on a Mac and got the labeling to end?

Thanks.

D.

On Oct 25, 2008, at 5:21 PM, Eric Firing wrote:

> David Arnold wrote:
>> All,
>> Does Matplotlib have a form of the clabel command that uses the   
>> switch manual, as in Matlab:
>> [c,h]=contour(x,y,z);
>> clabel(c,h,'manual')
>> Which allows the user to pick the contours to label with the mouse?
>
> Yes, this was added recently by David Kaplan.  It is in svn; I  
> don't know whether it has appeared a released version yet.
>
> The relevant part of the docstring, describing the keyword  
> argument, is:
>
>   *manual*:
> if *True*, contour labels will be placed manually using
> mouse clicks.  Click the first button near a contour to
> add a label, click the second button (or potentially both
> mouse buttons at once) to finish adding labels.  The third
> button can be used to remove the last label added, but
> only if labels are not inline.  Alternatively, the keyboard
> can be used to select label locations (enter to end label
> placement, delete or backspace act like the third mouse  
> button,
> and any other key will select a label location).
>
> Eric
>
>> David Arnold
>> College of the Redwoods
>> http://msemac.redwoods.edu/~darnold/index.php
>> - 
>> 
>> This SF.Net email is sponsored by the Moblin Your Move Developer's  
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win  
>> great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in  
>> the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] GTK warning (OS X fink)

2008-10-26 Thread Gideon Simpson
This might be something wrong with the way fink has built GTK, but the  
following warnings are showing up for me:

/opt/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py: 
72: GtkWarning: Unable to find default local directory monitor type
   gtk.main()
/opt/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py: 
1033: GtkWarning: Unable to find default local directory monitor type
   if self.run() != int(gtk.RESPONSE_OK):

-gideon


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why is wrapper module called "pylab" ?

2008-10-26 Thread chris
On Sun, Oct 26, 2008 at 11:51:48AM -0400, Charlie Moad wrote:
> The matplotlib.pyplot is favored over the pylab module now.

Thanks!  I find your comment very interesting.  As I have negligible experience
with Matlab, I'd love to use matplotlib.pyplot.

The problem is all the docs use pylab right?  Where find matplotlib.pyplot
examples?

Chris

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why is wrapper module called "pylab" ?

2008-10-26 Thread Charlie Moad
Pylab is just a name for a module in matplotlib that is supposed to mimic
matlab.  I would say its intent it to ease the transition for matlab users.
 It wouldn't really make sense to refer to matplotlib as pylab.  The
matplotlib.pyplot is favored over the pylab module now.
- Charlie

On Sun, Oct 26, 2008 at 1:28 AM, <[EMAIL PROTECTED]> wrote:

>
> So is matplotlib the name of the low level plotting engine?
>
> And, pylab is the user-friendly wrapper?
>
> Would it be ok to call the whole system "Pylab" instead of Matplotlib then?
>
>
> Chris
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why is wrapper module called "pylab" ?

2008-10-26 Thread massimo sandal
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

[EMAIL PROTECTED] ha scritto:
> So is matplotlib the name of the low level plotting engine?
> 
> And, pylab is the user-friendly wrapper?
> 
> Would it be ok to call the whole system "Pylab" instead of Matplotlib then?

Personally I'd say "no" exactly because they are two different things,
as you correctly pointed out.

m.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJBG/SpnWWEXZ5PA4RAg7nAKCJ1Jo78MApS3FP5t4FFLnMMel8mwCgpCHL
JSqrVwgyzX3JAD7y77Iyxnw=
=D9oR
-END PGP SIGNATURE-

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] regression coeffiecients

2008-10-26 Thread Oz Nahum
I'm answering to myself on the mailing list just in case it might help some
in the future.

As, someone pointed out the error is in the assignment operator:

I wrote in the code:
 sum1 =+ (i-mx)*(j-my)

which does not add the values but puts them.
Instead I should have wrote
 sum1 += (i-mx)*(j-my)

a little difference that does a lot... :-)

here is the correct function:


def slope(x,y):
sum1 = 0
sum2 = 0
mx = mean(x)
my = mean(y)
for i,j in zip(x,y):
sum1 += (i-mx)*(j-my)
print sum1
sum2 += (i-mx)**2
slope = sum1/sum2
return slope


-- 
 .''`.
: :' :  We are debian.org. Lower your prices,
`. `'   surrender your code.
  `-We will add your hardware and  software
distinctiveness to our own.
Resistance is futile.


   Imagine there's no countries
   It isn't hard to do
   Nothing to kill or die for
   And no religion too
   Imagine all the people
   Living life in peace

  You all must read 'The God Delusion'
  http://en.wikipedia.org/wiki/The_God_Delusion
---
when one person suffers from a delusion it is called insanity. When many
people suffer from a delusion it is called religion."
Robert Pirsig, Zen and the Art of Motorcycle Maintenance
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users