|
From: Pierre R. <co...@py...> - 2010-02-06 10:27:26
|
> > Date: Fri, 05 Feb 2010 12:59:41 -0800 From: Christopher Barker > <Chr...@no...> Subject: Re: [Matplotlib-users] Matplotlib > conflicts with IDLE To: mat...@li... > Message-ID: <4B6...@no...> 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 |
|
From: Gael V. <gae...@no...> - 2010-02-06 15:55:55
|
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=7200060&fromSeriesID=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. |
|
From: Pierre R. <co...@py...> - 2010-02-06 21:13:56
|
2010/2/6 Gael Varoquaux <gae...@no...>: > 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 |
|
From: Pierre R. <co...@py...> - 2010-02-07 08:58:39
|
Pierre Raybaut a écrit : > 2010/2/6 Gael Varoquaux <gae...@no...>: > >> 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 > Two screenshots to prove it :-) Running an example script including "pdb.set_trace()" in the external console: http://spyderlib.googlegroups.com/web/pdb_test.png Executing the same script from a Python interpreter within the external console: http://spyderlib.googlegroups.com/web/pdb_test2.png -Pierre |
|
From: Gael V. <gae...@no...> - 2010-02-07 09:08:20
|
On Sun, Feb 07, 2010 at 09:59:04AM +0100, Pierre Raybaut wrote: > Two screenshots to prove it :-) > > Running an example script including "pdb.set_trace()" in the external > console: > http://spyderlib.googlegroups.com/web/pdb_test.png > Executing the same script from a Python interpreter within the external > console: > http://spyderlib.googlegroups.com/web/pdb_test2.png Nice. I am not sure why when I tried it, it didn't work. I don't have spyder around to test. Gaël |
|
From: Pierre R. <co...@py...> - 2010-02-07 09:43:44
|
Gael Varoquaux a écrit : > On Sun, Feb 07, 2010 at 09:59:04AM +0100, Pierre Raybaut wrote: > >> Two screenshots to prove it :-) >> >> Running an example script including "pdb.set_trace()" in the external >> console: >> http://spyderlib.googlegroups.com/web/pdb_test.png >> Executing the same script from a Python interpreter within the external >> console: >> http://spyderlib.googlegroups.com/web/pdb_test2.png >> > > Nice. I am not sure why when I tried it, it didn't work. I don't have > spyder around to test. > > Gaël > I suppose you tried it in the interactive console (Spyder's internal console) which does not support pdb indeed. Anyway, the external console is probably not the ultimate scientific console mainly because it does not support matplotlib in interactive mode for now (actually, I still haven't heard any complaint on this point because people use the interactive console for interactive work -- e.g. analyzing and visualizing data -- and the external console for application development). But I guess I could make it work eventually. -Pierre |
|
From: <Dav...@se...> - 2010-02-08 20:29:32
|
Hey folks,
my problem may be obvious, but i can't seem to copy a plot from one canvas
to another.
# I have this object where whichCanvas is an instance of MplWidget (code
shown below)
self.whichCanvas.canvas.ax.plot(xData, yData, 'bo', linewidth=1.5,
linestyle='-')
# I want to copy the plot and axes to another MplWidget object
self.anotherCanvas.canvas
I've tried:
self.anotherCanvas.canvas.ax = self.whichCanvas.canvas.ax
self.anotherCanvas.canvas.draw()
and
self.anotherCanvas.canvas = self.whichCanvas.canvas
self.anotherCanvas.canvas.draw()
the plot doesn't seem to copy. Does any body more familiar with matplotlib
have any suggestions?
This is the MplWidget Class
***************************** MplWidget *******************************
from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg \
import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
class MplWidget(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
Regards,
Dave Tung
cell: 925-321-6657
office: 510-353-4770
dav...@se... |
|
From: Jae-Joon L. <lee...@gm...> - 2010-02-09 17:03:49
|
Copying a matplotlib canvas (or a figure, or an axes) is not easy. You cannot just rebind it. You need to copy all the hierarchy of underlying artists. Also the attributes of artists need to be adjusted accordingly. And best option in my opinion is just to create another canvas using the code that created the original canvas. Regards, -JJ On Mon, Feb 8, 2010 at 3:04 PM, <Dav...@se...> wrote: > Hey folks, > > my problem may be obvious, but i can't seem to copy a plot from one canvas > to another. > > # I have this object where whichCanvas is an instance of MplWidget (code > shown below) > > self.whichCanvas.canvas.ax.plot(xData, yData, 'bo', linewidth=1.5, > linestyle='-') > > > > > # I want to copy the plot and axes to another MplWidget object > > self.anotherCanvas.canvas > > > > I've tried: > > self.anotherCanvas.canvas.ax = self.whichCanvas.canvas.ax > self.anotherCanvas.canvas.draw() > > and > > self.anotherCanvas.canvas = self.whichCanvas.canvas > self.anotherCanvas.canvas.draw() > > the plot doesn't seem to copy. Does any body more familiar with matplotlib > have any suggestions? > > > > > > This is the MplWidget Class > ***************************** MplWidget ******************************* > > from PyQt4 import QtGui > from matplotlib.backends.backend_qt4agg \ > import FigureCanvasQTAgg as FigureCanvas > from matplotlib.figure import Figure > > > > > class MplCanvas(FigureCanvas): > def __init__(self): > self.fig = Figure() > self.ax = self.fig.add_subplot(111) > FigureCanvas.__init__(self, self.fig) > FigureCanvas.setSizePolicy(self, > QtGui.QSizePolicy.Expanding, > QtGui.QSizePolicy.Expanding) > FigureCanvas.updateGeometry(self) > > > > > class MplWidget(QtGui.QWidget): > > def __init__(self, parent = None): > QtGui.QWidget.__init__(self, parent) > self.canvas = MplCanvas() > self.vbl = QtGui.QVBoxLayout() > self.vbl.addWidget(self.canvas) > self.setLayout(self.vbl) > > > > Regards, > Dave Tung > > cell: 925-321-6657 > office: 510-353-4770 > dav...@se... > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |