Re: [Matplotlib-users] Matplotlib conflicts with IDLE

2010-02-06 Thread Pierre Raybaut

 Date: Fri, 05 Feb 2010 12:59:41 -0800 From: Christopher Barker 
 chris.bar...@noaa.gov Subject: Re: [Matplotlib-users] Matplotlib 
 conflicts with IDLE To: matplotlib-users@lists.sourceforge.net 
 Message-ID: 4b6c86bd.3090...@noaa.gov Content-Type: text/plain; 
 charset=ISO-8859-1; format=flowed David MacQuigg wrote:
  I can't get Matplotlib to work with IDLE. 
 

 Sorry, I don't know anything about IDLE, but...

   
  I'm running on Mac OS-X, so it looks like IPython is not an option.
 

 Why not? I use Ipython on OS-X all the time, and it is fabulous, really 
 fabulous.

   
   Also, I
  would rather stick with IDLE.  It is the perfect IDE for non-CS students 
  who
  shouldn't be spending their time on the complexities of a plotting package.
 

 Spyder:

 http://packages.python.org/spyder/

 Looks really promising, but I don't think they've got OS-X packages yet.

 -Chris
   

Hi there,

I can confirm that Spyder will make these GUI event loop issues go away 
(BTW I saw it running on OS-X, 2 days ago -- note that it requires PyQt 
to be installed). If you are familiar with MATLAB's IDE, you won't be 
disappointed because it works almost the same way (it even communicates 
well with MATLAB thanks to .mat files import/export features).

The great advantage of Spyder over other Python IDEs is the exclusive 
Workspace feature: like MATLAB's workspace, that is a global variable 
explorer allowing GUI-based edition of the most used Python objects 
(integers, floats, strings, dictionaries, lists, NumPy arrays, ...). It 
seems unbelievable, but Spyder is really the only IDE providing this 
feature which is IMHO essential for scientific users.

Cheers,
Pierre

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Uninstalling MatPlotLib (win7)? {Site-Packages?]

2010-02-06 Thread Christoph Gohlke
Depending on the version and installer used, manually remove

C:\Python25\Lib\site-packages\pylab.py
C:\Python25\Lib\site-packages\matplotlib
C:\Python25\Lib\site-packages\mpl_toolkits
C:\Python25\Lib\site-packages\matplotlib*.egg-info
C:\Python25\Removematplotlib.exe
C:\Python25\matplotlib-wininst.log

The packages dateutil and pytz are also installed along with matplotlib
but might be used by other packages too.

Christoph


On 2/5/2010 12:11 PM, Wayne Watson wrote:
 I'm working in IDLE in Win7. It seems to me it gets stuck in 
 site-packages under C:\Python25. Maybe this is as simple as deleting the 
 entry?
 
 Well, yes there's a MPL folder under site-packages and an info MPL file 
 of 540 bytes. There  are  also pylab.py, pyc,and py0 files under site. 
 What to do next?
 
 On 2/5/2010 7:13 AM, Wayne Watson wrote:
 I should have installed  numpy first, and got some errors installing
 MPL. I don't see an uninstall in Control Panel Add/Rmv.

 

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib conflicts with IDLE

2010-02-06 Thread Gael Varoquaux
On Sat, Feb 06, 2010 at 11:27:50AM +0100, Pierre Raybaut wrote:
  Why not? I use Ipython on OS-X all the time, and it is fabulous, really 
  fabulous.

Also, I would rather stick with IDLE.  It is the perfect IDE for
non-CS students who shouldn't be spending their time on the
complexities of a plotting package.

  Spyder:
  http://packages.python.org/spyder/
  Looks really promising, but I don't think they've got OS-X packages yet.

  [snip]

I'd like to pitch here the reason why I think there is a huge gain in
using IPython, because I think that not everybody realizes this.

For me, the killing feature is '%debug'. It enables you to drop in the
debugger post mortem. That means that if there is an exception raised
during a calculation, I can drop right where the exception occurred and
inspect the variables there. I can for instance check if a numpy array
has NaNs, and if so where they are, or if a matrix that is supposed to be
symmetric really is. I can also go up the call stack, and see what the
variables are at each level of function calls. Here is a trivial example:

In [1]: def f(x, y=0):
   ...: z = x+y
   ...: return 1/z
   ...: 

In [2]: f(0)
---
ZeroDivisionError Traceback (most recent call
last)

/home/varoquau/ipython console in module()

/home/varoquau/ipython console in f(x, y)

ZeroDivisionError: integer division or modulo by zero

In [3]: %debug
 ipython console(3)f()

ipdb print x
0
ipdb print y
0
ipdb print z
0
ipdb 

Jose Unpinco has written a nice video introducing these features:
http://showmedo.com/videotutorials/video?name=7200060fromSeriesID=720

When you start having a somewhat complex set of functions that call
each other, or when you are getting failures with somebody else's code,
this is priceless. This is so useful that to debug some code that, when I
am trying to understand why some code is not working the way it should
be, I will purposely add an exception, to be able to introspect the code.
Granted, adding pdb.set_trace() will work without IPython[*], but I find
it very useful.

I am to the point where the post-mortem debugging of IPython may be the
killing feature of Python that I lack with every other work flow. The
reason being that I develop data processing code, and that I am always
experiment and trying to implement new algorithms. As a result, my code
is seldom mature, and I often spend time tracking down where bugs lie.
Also, running my various processing steps take a while. This is why I
rely a lot on post-mortem: I find bugs after minutes or hours of number
crunching, and I want to be as efficient as possible. Post-portem enables
me not to restart the script that crashed.

My 2 cents,

Gaël

[*] It will not work in Spyder as it is quite challenging to have these
features requiring user terminal interaction in a GUI.


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Comet

2010-02-06 Thread David Arnold
Hi Eric,

Matlab has two commands, comet and comet3, that animate the path. They are used 
as in the following Matlab code:

t=linspace(0,2*pi,2000);
x=-sin(t);
y=cos(t);
comet(x,y)

What then happens is the path is drawn live, as in my python code below.

This is especially useful when teaching parametric equations in calculus. A 
typical question in that section might be: find a parametrization for the unit 
circle that starts at (0,1) and moves around the circle one time in the 
counterclockwise direction. In this situation, the following is not helpful:

t=linspace(0,2*pi,2000);
x=-sin(t);
y=cos(t);
plot(x,y)

Because the student just sees sees the finished path. The comet command, on 
the other hand, allows the student to see that path as it is traced out in 
real time.

David.

On Feb 6, 2010, at 9:09 AM, Eric Firing wrote:

 David Arnold wrote:
 All,
 I am still wondering why there is no comet command in matplotlib. I was 
 successful with the following:
 import matplotlib.pyplot as plt
 import numpy as np
 len=200
 t=np.linspace(0,2*np.pi,len)
 x=np.cos(t)
 y=np.sin(t)
 xd=[x[0]]
 yd=[y[0]]
 l,=plt.plot(xd,yd)
 plt.axis([-1,1,-1,1])
 for i in np.arange(1,len):
  xd.append(x[i])
  yd.append(y[i])
  l.set_xdata(xd)
  l.set_ydata(yd)
  plt.draw()
  
 plt.show()
 But it seems that a comet function added to the matplotlib library would 
 greatly simplify things for students using the interactive pylab in ipython.
 
 I don't understand--what's the point of the example?  What is comet, and 
 how does it simplify anything?
 
 Eric
 


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] MatPlotLib Usage FAQ Page Needs Some Work.

2010-02-06 Thread Wayne Watson




I can write some fairly decent Python code. In fact, I've recently
written 400-500 lines often using numpy. There are still a number of
concepts that are fuzzy. I have a modest familiarity of OOP from years
ago with C++, and a few things I've picked up from Python. Five years
ago, I was working with Matlab, but my knowledge has diminished. 

Nevertheless, I finally decided to graphics, MPL, to display what I'm
doing. I've had some modest success using very basic operations,
sometime guessing at usage along the way. I've looked through the
bewildering array of MPL, pylab, pyplot docs and examples. It's
slowly fitting together. I decided to give the following web page a
closer look to see what are the differences between the MPL players.
http://matplotlib.sourceforge.net/faq/usage_faq.html. I've
copied a few paragraphs at the start of the FAQ below.

I've studied it fairly carefully, and more or less comprehend it.
However, why does it need words like state-machine, convenience
functions, and object-oriented. I'm familiar with them all, but the
concepts really aren't presented clearly in relationship to the code
below. I'm not even sure if we are pro-pylab or pyplot as the
preferred-style. What part of some of the code is pyplot or otherwise?
Highlight it. Not everyone is clear on some of the assumed Python
concepts here.

It seems as though Python has a way of aligning itself with other
tools, For example, Matlab and Tk. Despite the apparent appeal of MPL
and Tkinter, seldom, maybe never, is anyone who is attracted to these
ideas really familiar with the tools on which they are based. (Perhaps
its the other way. Everyone knows them )Yet no explanation is
offered. What would that take, 3 pages each? 


Matplotlib, pylab, and pyplot: how are they related?
Matplotlib is the whole package; pylab is a module in matplotlib
that gets
installed alongside matplotlib;
and matplotlib.pyplot
is a
module in matplotlib.
Pyplot provides a Matlab-style state-machine interface to
the underlying object-oriented plotting library in matplotlib.
Pylab combines the pyplot functionality (for plotting) with the
numpy
functionality (for mathematics and for working with arrays)
in a single namespace, making that namespace
(or environment) even more Matlab-like. This is what you get if
you use the
ipython shell with the -pylab option, which imports
everything
from pylab and makes plotting fully interactive.

...

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...
=



-- 
My life in two words. "Interrupted Projects." -- WTW (quote originator)



--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Surface Plot

2010-02-06 Thread Ted Kord
Hi

I'd like to generate a surface plot using mplot3d. However, Z is not a
function of X and/or Y. It's just a set of scalar values. So, the following
doesn't work:

X = np.arange(2, 102, 2)
Y = np.arange(0, 15.15, 0.15)
X, Y = np.meshgrid(X, Y)
Z = f[2]
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)

Is there a way that I can do this?

Thank you.

Ted
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib conflicts with IDLE

2010-02-06 Thread Pierre Raybaut
2010/2/6 Gael Varoquaux gael.varoqu...@normalesup.org:
 On Sat, Feb 06, 2010 at 11:27:50AM +0100, Pierre Raybaut wrote:
 When you start having a somewhat complex set of functions that call
 each other, or when you are getting failures with somebody else's code,
 this is priceless. This is so useful that to debug some code that, when I
 am trying to understand why some code is not working the way it should
 be, I will purposely add an exception, to be able to introspect the code.
 Granted, adding pdb.set_trace() will work without IPython[*], but I find
 it very useful.

 [*] It will not work in Spyder as it is quite challenging to have these
 features requiring user terminal interaction in a GUI.

Actually it works in Spyder too (in the external console which is
executed in a another process).
;-)

-Pierre

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Comet

2010-02-06 Thread Goyo
Hi David,

El sáb, 06-02-2010 a las 10:21 -0800, David Arnold escribió:
 Hi Eric,
 
 Matlab has two commands, comet and comet3, that animate the path. They are 
 used as in the following Matlab code:
 
 t=linspace(0,2*pi,2000);
 x=-sin(t);
 y=cos(t);
 comet(x,y)

You can just write the function:

import matplotlib.pyplot as plt

def comet(x, y, fmt='', step=1, **kwargs):
l, = plt.plot(x, y, fmt, **kwargs)
num_points = len(x)
for i in xrange(1, num_points + 1, step):
l.set_data(x[:i], y[:i])
plt.draw()
l.set_data(x, y)
plt.draw()

I think this could be better done using animation features of
matplotlib, but I never used them and I think they varies across
toolkits. Search the docs for animation examples anyway.

Goyo

 
 What then happens is the path is drawn live, as in my python code below.
 
 This is especially useful when teaching parametric equations in calculus. A 
 typical question in that section might be: find a parametrization for the 
 unit circle that starts at (0,1) and moves around the circle one time in the 
 counterclockwise direction. In this situation, the following is not helpful:
 
 t=linspace(0,2*pi,2000);
 x=-sin(t);
 y=cos(t);
 plot(x,y)
 
 Because the student just sees sees the finished path. The comet command, on 
 the other hand, allows the student to see that path as it is traced out in 
 real time.
 
 David.
 
 On Feb 6, 2010, at 9:09 AM, Eric Firing wrote:
 
  David Arnold wrote:
  All,
  I am still wondering why there is no comet command in matplotlib. I was 
  successful with the following:
  import matplotlib.pyplot as plt
  import numpy as np
  len=200
  t=np.linspace(0,2*np.pi,len)
  x=np.cos(t)
  y=np.sin(t)
  xd=[x[0]]
  yd=[y[0]]
  l,=plt.plot(xd,yd)
  plt.axis([-1,1,-1,1])
  for i in np.arange(1,len):
 xd.append(x[i])
 yd.append(y[i])
 l.set_xdata(xd)
 l.set_ydata(yd)
 plt.draw()
 
  plt.show()
  But it seems that a comet function added to the matplotlib library would 
  greatly simplify things for students using the interactive pylab in 
  ipython.
  
  I don't understand--what's the point of the example?  What is comet, and 
  how does it simplify anything?
  
  Eric
  
 
 
 --
 The Planet: dedicated and managed hosting, cloud storage, colocation
 Stay online with enterprise data centers and the best network in the business
 Choose flexible plans and management services without long-term contracts
 Personal 24x7 support from experience hosting pros just a phone call away.
 http://p.sf.net/sfu/theplanet-com
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] clabel manual

2010-02-06 Thread Jae-Joon Lee
This is a known bug, and I think I fixed it in the svn. Meanwhile, you
may use the monkey patching.
Insert these lines in your script (before you call clabel).

Regards,

-JJ


import matplotlib.blocking_input as blocking_input
def mouse_event_stop(self, event ):
blocking_input.BlockingInput.pop(self,-1)
self.fig.canvas.stop_event_loop()
def add_click(self, event):
self.button1(event)
def pop_click(self, event, index=-1):
if self.inline:
pass
else:
self.cs.pop_label()
self.cs.ax.figure.canvas.draw()

blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
blocking_input.BlockingMouseInput.add_click = add_click
blocking_input.BlockingMouseInput.pop_click = pop_click



On Sat, Feb 6, 2010 at 2:01 AM, David Arnold dwarnol...@suddenlink.net wrote:
 Hi,

 I'm trying to get manual labeling of contours to work:

 import numpy as np
 import matplotlib.mlab as mlab
 import matplotlib.pyplot as plt

 delta = 0.025
 x = np.arange(-3.0, 3.0, delta)
 y = np.arange(-2.0, 2.0, delta)
 X, Y = np.meshgrid(x, y)
 Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
 Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
 # difference of Gaussians
 Z = 10.0 * (Z2 - Z1)

 plt.figure()
 CS = plt.contour(X, Y, Z, 6,
                 linewidths=np.arange(.5, 4, .5),
                 colors=('r', 'green', 'blue', (1,1,0), '#af', '0.5')
                 )
 plt.clabel(CS, fontsize=9, inline=1, manual=True)
 plt.title('Crazy lines')

 plt.show()

 On my macbook, clicking with the touchpad does not seem to work.

 Any ideas?

 David.

 --
 The Planet: dedicated and managed hosting, cloud storage, colocation
 Stay online with enterprise data centers and the best network in the business
 Choose flexible plans and management services without long-term contracts
 Personal 24x7 support from experience hosting pros just a phone call away.
 http://p.sf.net/sfu/theplanet-com
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] clabel manual

2010-02-06 Thread David Arnold
JJ,

Very nice repair, as this works precisely as it should. I use this tool in 
Matlab all the time when teaching multivariable calculus. 

D.

On Feb 6, 2010, at 2:41 PM, Jae-Joon Lee wrote:

 This is a known bug, and I think I fixed it in the svn. Meanwhile, you
 may use the monkey patching.
 Insert these lines in your script (before you call clabel).
 
 Regards,
 
 -JJ
 
 
 import matplotlib.blocking_input as blocking_input
 def mouse_event_stop(self, event ):
blocking_input.BlockingInput.pop(self,-1)
self.fig.canvas.stop_event_loop()
 def add_click(self, event):
self.button1(event)
 def pop_click(self, event, index=-1):
if self.inline:
pass
else:
self.cs.pop_label()
self.cs.ax.figure.canvas.draw()
 
 blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
 blocking_input.BlockingMouseInput.add_click = add_click
 blocking_input.BlockingMouseInput.pop_click = pop_click
 
 
 
 On Sat, Feb 6, 2010 at 2:01 AM, David Arnold dwarnol...@suddenlink.net 
 wrote:
 Hi,
 
 I'm trying to get manual labeling of contours to work:
 
 import numpy as np
 import matplotlib.mlab as mlab
 import matplotlib.pyplot as plt
 
 delta = 0.025
 x = np.arange(-3.0, 3.0, delta)
 y = np.arange(-2.0, 2.0, delta)
 X, Y = np.meshgrid(x, y)
 Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
 Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
 # difference of Gaussians
 Z = 10.0 * (Z2 - Z1)
 
 plt.figure()
 CS = plt.contour(X, Y, Z, 6,
 linewidths=np.arange(.5, 4, .5),
 colors=('r', 'green', 'blue', (1,1,0), '#af', '0.5')
 )
 plt.clabel(CS, fontsize=9, inline=1, manual=True)
 plt.title('Crazy lines')
 
 plt.show()
 
 On my macbook, clicking with the touchpad does not seem to work.
 
 Any ideas?
 
 David.
 
 --
 The Planet: dedicated and managed hosting, cloud storage, colocation
 Stay online with enterprise data centers and the best network in the business
 Choose flexible plans and management services without long-term contracts
 Personal 24x7 support from experience hosting pros just a phone call away.
 http://p.sf.net/sfu/theplanet-com
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Axes3D rotation not working when embedded in backend

2010-02-06 Thread Ben Axelrod
I looked into this issue a little bit and found that the FigureCanvas must be 
set on the Figure before the 3D axes is instantiated.  A simple re-ordering of 
the lines in the code below makes mouse rotation work again.

# ...
self.figure = Figure()
self.canvas = FigureCanvas(self, -1, self.figure)
#You must set up the canvas before creating the 3D axes
self.axes = Axes3D(self.figure)
# ...

Perhaps this should be documented somehow?  Or maybe a new mplot3d example code 
should be added.  Or maybe 
Axes3D.mouse_init() should warn the user if self.figure.canvas is None.

-Ben


-Original Message-
From: Ben Axelrod [mailto:baxel...@coroware.com] 
Sent: Monday, February 01, 2010 3:56 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Axes3D rotation not working when embedded in backend

I would like to use Axes3D embedded in Wx.  This works, but there is no mouse 
rotation.  Clicking and dragging the mouse on the plot does not rotate the 3D 
axes like it does in the scatter3d_demo.py.  I tried: WX, WXAgg, and TkAgg 
with similar results.  Can this be fixed soon, or can someone point me to where 
I can try to fix it?

I tested with the latest SVN tree on Linux and Windows.

Thanks,
-Ben

Below is some sample code adapted from embedding_in_wx2.py, but with an 
Axes3D instead of the regular plot:

#!/usr/bin/env python
# adapted from example code embedding_in_wx2.py

# Used to guarantee to use at least Wx2.8 import wxversion
wxversion.ensureMinimal('2.8')

import numpy as np

import matplotlib

# uncomment the following to use wx rather than wxagg
#matplotlib.use('WX')
#from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas

# comment out the following to use wx rather than wxagg
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

from matplotlib.backends.backend_wx import NavigationToolbar2Wx

from matplotlib.figure import Figure
from mpl_toolkits.mplot3d import Axes3D
import wx

class CanvasFrame(wx.Frame):

def __init__(self):
wx.Frame.__init__(self,None,-1,
 'CanvasFrame',size=(550,350))

self.SetBackgroundColour(wx.NamedColor(WHITE))

self.figure = Figure()
self.axes = Axes3D(self.figure)

xs = np.random.rand(100)
ys = np.random.rand(100)
zs = np.random.rand(100)
self.axes.scatter(xs, ys, zs)

self.canvas = FigureCanvas(self, -1, self.figure)

self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()

self.add_toolbar()  # comment this out for no toolbar


def add_toolbar(self):
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
if wx.Platform == '__WXMAC__':
# Mac platform (OSX 10.3, MacPython) does not seem to cope with
# having a toolbar in a sizer. This work-around gets the buttons
# back, but at the expense of having the toolbar at the top
self.SetToolBar(self.toolbar)
else:
# On Windows platform, default window size is incorrect, so set
# toolbar width to figure width.
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.canvas.GetSizeTuple()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
# As noted above, doesn't work for Mac.
self.toolbar.SetSize(wx.Size(fw, th))
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
# update the axes menu on the toolbar
self.toolbar.update()


def OnPaint(self, event):
self.canvas.draw()

class App(wx.App):

def OnInit(self):
'Create the main window and insert the custom frame'
frame = CanvasFrame()
frame.Show(True)

return True

app = App(0)
app.MainLoop()
#end code




--
The Planet: dedicated and managed hosting, cloud storage, colocation Stay 
online with enterprise data centers and the best network in the business Choose 
flexible plans and management services without long-term contracts Personal 
24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros 

Re: [Matplotlib-users] clabel manual

2010-02-06 Thread Jae-Joon Lee
The above version has some typos (while it works it had some
side-effects), here is the corrected one.

-JJ


import matplotlib.blocking_input as blocking_input
if blocking_input.BlockingMouseInput.add_click ==
blocking_input.BlockingContourLabeler.add_click:
def mouse_event_stop(self, event ):
blocking_input.BlockingInput.pop(self,-1)
self.fig.canvas.stop_event_loop()
def add_click(self, event):
self.button1(event)
def pop_click(self, event, index=-1):
if self.inline:
pass
else:
self.cs.pop_label()
self.cs.ax.figure.canvas.draw()

blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
blocking_input.BlockingContourLabeler.add_click = add_click
blocking_input.BlockingContourLabeler.pop_click = pop_click




On Sat, Feb 6, 2010 at 5:52 PM, David Arnold dwarnol...@suddenlink.net wrote:
 JJ,

 Very nice repair, as this works precisely as it should. I use this tool in 
 Matlab all the time when teaching multivariable calculus.

 D.

 On Feb 6, 2010, at 2:41 PM, Jae-Joon Lee wrote:

 This is a known bug, and I think I fixed it in the svn. Meanwhile, you
 may use the monkey patching.
 Insert these lines in your script (before you call clabel).

 Regards,

 -JJ


 import matplotlib.blocking_input as blocking_input
 def mouse_event_stop(self, event ):
    blocking_input.BlockingInput.pop(self,-1)
    self.fig.canvas.stop_event_loop()
 def add_click(self, event):
    self.button1(event)
 def pop_click(self, event, index=-1):
    if self.inline:
        pass
    else:
        self.cs.pop_label()
        self.cs.ax.figure.canvas.draw()

 blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
 blocking_input.BlockingMouseInput.add_click = add_click
 blocking_input.BlockingMouseInput.pop_click = pop_click



 On Sat, Feb 6, 2010 at 2:01 AM, David Arnold dwarnol...@suddenlink.net 
 wrote:
 Hi,

 I'm trying to get manual labeling of contours to work:

 import numpy as np
 import matplotlib.mlab as mlab
 import matplotlib.pyplot as plt

 delta = 0.025
 x = np.arange(-3.0, 3.0, delta)
 y = np.arange(-2.0, 2.0, delta)
 X, Y = np.meshgrid(x, y)
 Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
 Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
 # difference of Gaussians
 Z = 10.0 * (Z2 - Z1)

 plt.figure()
 CS = plt.contour(X, Y, Z, 6,
                 linewidths=np.arange(.5, 4, .5),
                 colors=('r', 'green', 'blue', (1,1,0), '#af', '0.5')
                 )
 plt.clabel(CS, fontsize=9, inline=1, manual=True)
 plt.title('Crazy lines')

 plt.show()

 On my macbook, clicking with the touchpad does not seem to work.

 Any ideas?

 David.

 --
 The Planet: dedicated and managed hosting, cloud storage, colocation
 Stay online with enterprise data centers and the best network in the 
 business
 Choose flexible plans and management services without long-term contracts
 Personal 24x7 support from experience hosting pros just a phone call away.
 http://p.sf.net/sfu/theplanet-com
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users