[Matplotlib-users] Little help needed with pqt ...
Hello, I face a very boring problem. Here is a little modified pyqt widget example found on matplotlib website. Basicaly I've just added a tab widget and inside it a matplotlib widget. Sadly, on creation the widget don't get the full size of the PA_tab widget :( BUT once I resize manually the app all became OK... To be honest I've got NO idea of what is the problem :( Any direction highly appreciated! Laurent matplotlib: __version__ = '0.98.5.2' And pyqt: 4.4.3.6 #!/usr/bin/env python # embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases # # Copyright (C) 2005 Florent Rougon # 2006 Darren Dale # # This file is an example program for matplotlib. It may be used and # modified with no restriction; raw copies as well as modified versions # may be distributed without limitation. import sys, os, random from PyQt4 import QtGui, QtCore from numpy import arange, sin, pi from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure progname = os.path.basename(sys.argv[0]) progversion = "0.1" class MyMplCanvas(FigureCanvas): """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" def __init__(self, parent=None, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) # We want the axes cleared every time plot() is called self.axes.hold(False) self.compute_initial_figure() # FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) def compute_initial_figure(self): pass class MyStaticMplCanvas(MyMplCanvas): """Simple canvas with a sine plot.""" def compute_initial_figure(self): t = arange(0.0, 3.0, 0.01) s = sin(2*pi*t) self.axes.plot(t, s) class MyDynamicMplCanvas(MyMplCanvas): """A canvas that updates itself every second with a new plot.""" def __init__(self, *args, **kwargs): MyMplCanvas.__init__(self, *args, **kwargs) timer = QtCore.QTimer(self) QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), self.update_figure) timer.start(1000) def compute_initial_figure(self): self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r') def update_figure(self): # Build a list of 4 random integers between 0 and 10 (both inclusive) l = [ random.randint(0, 10) for i in xrange(4) ] self.axes.plot([0, 1, 2, 3], l, 'r') self.draw() class ApplicationWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("application main window") self.centralwidget = QtGui.QWidget(self) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.MainTab = QtGui.QTabWidget(self.centralwidget) self.verticalLayout.addWidget(self.MainTab) self.PA_tab = QtGui.QWidget() self.MainTab.addTab(self.PA_tab, "") toto = MyDynamicMplCanvas(self.PA_tab) self.vLayout = QtGui.QVBoxLayout(self.PA_tab) self.vLayout.addWidget(toto) self.setCentralWidget(self.centralwidget) self.resize(QtCore.QSize(1024,900)) def fileQuit(self): self.close() def closeEvent(self, ce): self.fileQuit() def about(self): QtGui.QMessageBox.about(self, "About %s" % progname, u"""%(prog)s version %(version)s Copyright \N{COPYRIGHT SIGN} 2005 Florent Rougon, 2006 Darren Dale This program is a simple example of a Qt4 application embedding matplotlib canvases. It may be used and modified with no restriction; raw copies as well as modified versions may be distributed without limitation.""" % {"prog": progname, "version": progversion}) qApp = QtGui.QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("%s" % progname) aw.show() sys.exit(qApp.exec_()) #qApp.exec_() -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Re :Re: Little help need ed with pqt ...
Hi Darren, Thanks for your answer. ... I've updated to matplotlib 0.99 since the last email... and the bug disappeared :) Must be a bug of previous version since I had ever added a layout to the central widget! Thanks anyway for your help! On Fri, Sep 11, 2009 at 5:52 PM, Laurent Dufrechou laurent.dufrec...@gmail.com> wrote: > Hello, > > I face a very boring problem. > Here is a little modified pyqt widget example found on matplotlib website. > Basicaly I've just added a tab widget and inside it a matplotlib widget. > > Sadly, on creation the widget don't get the full size of the PA_tab widget > :( > BUT once I resize manually the app all became OK... > > To be honest I've got NO idea of what is the problem :( > > Any direction highly appreciated! Try adding a layout to the central widget and adding your tab widget to that layout. Darren -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Testing email becuase my previuous didn't want to appear...
. Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Little issue with blitting technique
Hello, I've just discovered blitting technique to improve performances. I'm using this example http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4.html I encounter an issue if instead of using subplot I use add_axes method to hand define where I want my plot. In this case blitting is no more working like if restore_region was not restoring context. def __init__(self): FigureCanvas.__init__(self, Figure()) #self.ax = self.figure.add_subplot(111) self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2]) Any idea why in this case the example given is not working? Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Little issue with blitting technique [Update]
Hello, Continuing on my previous email, I'm using this example: http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4.html def __init__(self): FigureCanvas.__init__(self, Figure()) self.ax = self.figure.add_subplot(111) self.ax.set_position([0.1,0.05,0.5,0.9]) works, but: def __init__(self): FigureCanvas.__init__(self, Figure()) self.ax = self.figure.add_subplot(111) self.ax.set_position([0.1,0.1,0.5,0.9]) is not working L, the region is wrongly blitted and some part of the graph is not restored. I think there is a bug in the refresh of the bounding box or something like this. Using matplotlib 0.99.1.1 python2.5 win32 pyqt4 4.4.3.7 (given with python(x,y) 2.1.17) Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Some icons do not showup after packaging with py2exe or pyinstaller
Hello, Whether method I use to package my python app, I always reach the issue where the toolbar does not display some icons whiel the "subplot" is well displayed. Each time the packaging method copy mpl-data where the .exe is created so file are or should be at the right location. Does anybody has encountered this issue /solved it? If not, can someone explain me the basic process behind finding the pictures inside matplotlib? So I'l try to debug this with py2exe and pyinstaller team. Ps: using matplotlib 0.99.1 + pyqt 4.4 Thx a lot for any direction! Laurent <>-- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Little issue with blitting technique
Hello, I've just discovered blitting technique to improve performances. I'm using this example http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4. html I encounter an issue if instead of using subplot I use add_axes method to hand define where I want my plot. In this case blitting is no more working like if restore_region was not restoring context... def __init__(self): FigureCanvas.__init__(self, Figure()) #self.ax = self.figure.add_subplot(111) self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2]) Any idea why in this case the example given is not working? Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Some icons do not showup after packaging with py2exe or pyinstaller
Hello, Whether method I use to package my python app, I always reach the issue where the toolbar does not display some icons whiel the "subplot" is well displayed. Each time the packaging method copy mpl-data where the .exe is created so file are or should be at the right location. Does anybody has encountered this issue /solved it? If not, can someone explain me the basic process behind finding the pictures inside matplotlib? So I'l try to debug this with py2exe and pyinstaller team. Ps: using matplotlib 0.99.1 + pyqt 4.4 Thx a lot for any direction! Laurent <>-- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Little issue with blitting technique
Hello, I've tested so far with wx and QT4 backend. The two are buggy. Easy way to reproduce the bug (another way I mean) ax = p.subplot(212) ax2 = p.subplot(211) and the two backends got the same error. Note that I'm under windows. I'll try under linux tonight just to check. I'll also try gtk backend as you suggest. Update in next email :) > -Message d'origine- > De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com] > Envoyé : mardi 13 octobre 2009 18:36 > À : Laurent Dufrechou > Cc : matplotlib-users@lists.sourceforge.net > Objet : Re: [Matplotlib-users] Little issue with blitting technique > > I haven't tested it with qt4, but with gtk, add_axes DOES work. > > So, can you try other backends and see if they work? > > And, I believe that add_subplot -> add_axes is a only change you made? > > Unless the problem is persistent among other backends, I hope other > developers who use qt4 backend step in and help. > > Regards, > > -JJ > > > On Thu, Oct 8, 2009 at 11:30 AM, Laurent Dufrechou > wrote: > > Hello, > > > > > > > > I’ve just discovered blitting technique to improve performances. > > > > I’m using this example > > > http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4 > .html > > > > > > > > I encounter an issue if instead of using subplot I use add_axes > method to > > hand define where I want my plot. > > > > In this case blitting is no more working like if restore_region was > not > > restoring context… > > > > > > > > def __init__(self): > > > > FigureCanvas.__init__(self, Figure()) > > > > > > > > #self.ax = self.figure.add_subplot(111) > > > > self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2]) > > > > > > > > Any idea why in this case the example given is not working? > > > > > > > > Cheers, > > > > Laurent > > > > - > - > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart > your > > developing skills, take BlackBerry mobile applications to market and > stay > > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > > http://p.sf.net/sfu/devconference > > ___ > > Matplotlib-users mailing list > > Matplotlib-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Little issue with blitting technique
Bug reported: https://sourceforge.net/tracker/index.php?func=detail&aid=2880692&group_id=80706&atid=560720 Does anybody where I could dig a little to try to correct it? It a really needed feature for me, so if I could help... Cheers, Laurent > -Message d'origine- > De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com] > Envoyé : jeudi 15 octobre 2009 05:23 > À : Laurent Dufrechou > Cc : matplotlib-users@lists.sourceforge.net > Objet : Re: [Matplotlib-users] Little issue with blitting technique > > On Tue, Oct 13, 2009 at 1:02 PM, Laurent Dufrechou > wrote: > > Hello, > > > > I've tested so far with wx and QT4 backend. > > The two are buggy. > > Easy way to reproduce the bug (another way I mean) > > > > ax = p.subplot(212) > > ax2 = p.subplot(211) > > > > On mac with wxgtk, it works fine. > Maybe this is an windows only issue. > > > and the two backends got the same error. > > Since nobody steped in, and I don't use windows, can you file a bug > report. > > http://sourceforge.net/tracker/?atid=560720&group_id=80706&func=browse > > Please provide a short, complete example that reproduces the bug. Also > the error message you get. > > -JJ > > > > > > Note that I'm under windows. I'll try under linux tonight just to > check. > > I'll also try gtk backend as you suggest. > > > > Update in next email :) > > > >> -Message d'origine- > >> De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com] > >> Envoyé : mardi 13 octobre 2009 18:36 > >> À : Laurent Dufrechou > >> Cc : matplotlib-users@lists.sourceforge.net > >> Objet : Re: [Matplotlib-users] Little issue with blitting technique > >> > >> I haven't tested it with qt4, but with gtk, add_axes DOES work. > >> > >> So, can you try other backends and see if they work? > >> > >> And, I believe that add_subplot -> add_axes is a only change you > made? > >> > >> Unless the problem is persistent among other backends, I hope other > >> developers who use qt4 backend step in and help. > >> > >> Regards, > >> > >> -JJ > >> > >> > >> On Thu, Oct 8, 2009 at 11:30 AM, Laurent Dufrechou > >> wrote: > >> > Hello, > >> > > >> > > >> > > >> > I’ve just discovered blitting technique to improve performances. > >> > > >> > I’m using this example > >> > > >> > http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4 > >> .html > >> > > >> > > >> > > >> > I encounter an issue if instead of using subplot I use add_axes > >> method to > >> > hand define where I want my plot. > >> > > >> > In this case blitting is no more working like if restore_region > was > >> not > >> > restoring context… > >> > > >> > > >> > > >> > def __init__(self): > >> > > >> > FigureCanvas.__init__(self, Figure()) > >> > > >> > > >> > > >> > #self.ax = self.figure.add_subplot(111) > >> > > >> > self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2]) > >> > > >> > > >> > > >> > Any idea why in this case the example given is not working? > >> > > >> > > >> > > >> > Cheers, > >> > > >> > Laurent > >> > > >> > -- > --- > >> - > >> > Come build with us! The BlackBerry(R) Developer Conference in SF, > CA > >> > is the only developer event you need to attend this year. > Jumpstart > >> your > >> > developing skills, take BlackBerry mobile applications to market > and > >> stay > >> > ahead of the curve. Join us from November 9 - 12, 2009. Register > now! > >> > http://p.sf.net/sfu/devconference > >> > ___ > >> > Matplotlib-users mailing list > >> > Matplotlib-users@lists.sourceforge.net > >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > > >> > > > -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] TR: Cleaver way to do a scrolling imshow?
Hello, I'm investigating a way to make a sort of imshow that is scrolling from right to left. My idea is to copy in a blit buffer from (1,0) to (xmax,ymax). Blit it @(0,0) (xmax-1,ymax) And then draw a cmap'ed line @x=xmax. So here are my question: How to draw a line that use a cmap=jet (for example)? I've taken a look at Line2D but it has no cmap argument. The only thing I've found is drawing a line with only one color. Any idea appreciated! Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Cleaver way to do a scrolling imshow?
Hello, I'm investigating a way to make a sort of imshow that is scrolling from right to left. My idea is to copy in a blit buffer from (1,0) to (xmax,ymax). Blit it @(0,0) (xmax-1,ymax) And then draw a cmap'ed line @x=xmax. So here are my question: How to draw a line that use a cmap=jet (for example)? I've taken a look at Line2D but it has no cmap argument. The only thing I've found is drawing a line with only one color... Any idea appreciated! Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] set figure position
Hi marie, You can define exactly the size and position of your plot like this: fig = Figure() axe = fig.add_axes([pos_x,pos_y,size_x,size_y]) axe.plot(x, y, 'b') where pos_x,pos_y is a number (0mailto:marie.delafonta...@yahoo.com] Envoyé : dimanche 22 novembre 2009 18:05 À : matplotlib-users@lists.sourceforge.net Objet : [Matplotlib-users] set figure position We have recently switched to matplotlib after having done all plotting with pure wxPython for years. There is one problem we cannot solve. With wxPython we are free to set the geometry (position and size) of each Frame anywhere on the screen. We have developed a heuristic solution which packs the Frames automatically according to a pattern that can be recognized after a user has manually repositioned a few Frames on the screen. For example, some users tend to align their figures in a row, others subdivide the available space for different groups of figures, and so on. Please let us know if anyone is interested to integrate this heuristic packing into matplotlib. The important question is: How can we set the position of a Figure on the screen using matplotlib? There is a function Figure.set_size_inches, but no function to move the Figure to a new position. Please help. Regards, Marie __ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bliting speed improvment patch (QT4Agg backend) + example of sliding demo
Hi there, Finally with lot of try I've finally managed to make blitting of a cmap working. I've also patched QT4agg backend, to make a redraw immediately. (replaced self.draw by self.repaint) In my current project I was able to stream a 655KB network stream, do demodulation of an IQ stream and display the spectrogram in real time (4096 pixel per 1024) with matplotlib and QT4 backend, thx to the patch + blitting example attached. Without patch, the refrech was veeery long. (waiting for QT loop to execute code wen it wanted.) And do NOT always work. If you've got a powerfull pc you've got chance to see only white background... (or simply the loop timer to 0, you will see that without patch blit does not work). Only tested under windows currently, 'cause my project is on windows currently... There is one bug in the example, that I didn't manage to correct yet. Depending on screen resolution, the color of the cmap blitted area can be kind of alpha'ed. (that is look like a little bit transparent...) , Any idea on the root of this issue? By the way to make the example work I needed to do this: self.ax2.draw_artist(self.line2) self.blit(self.ax2.bbox) self.restore_region(self.background2) that is blit before restore... don't understand why yet. Any comment welcomed. Is there any chance, after review, to find a way to include this in main trunk? What do think about this? Cheers, Laurent """ Render to qt from agg """ from __future__ import division import os, sys import matplotlib from matplotlib.figure import Figure from backend_agg import FigureCanvasAgg from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\ show, draw_if_interactive, backend_version, \ NavigationToolbar2QT DEBUG = False def new_figure_manager( num, *args, **kwargs ): """ Create a new figure manager instance """ if DEBUG: print 'backend_qtagg.new_figure_manager' FigureClass = kwargs.pop('FigureClass', Figure) thisFig = FigureClass( *args, **kwargs ) canvas = FigureCanvasQTAgg( thisFig ) return FigureManagerQT( canvas, num ) class NavigationToolbar2QTAgg(NavigationToolbar2QT): def _get_canvas(self, fig): return FigureCanvasQTAgg(fig) class FigureManagerQTAgg(FigureManagerQT): def _get_toolbar(self, canvas, parent): # must be inited after the window, drawingArea and figure # attrs are set if matplotlib.rcParams['toolbar']=='classic': print "Classic toolbar is not supported" elif matplotlib.rcParams['toolbar']=='toolbar2': toolbar = NavigationToolbar2QTAgg(canvas, parent) else: toolbar = None return toolbar class FigureCanvasQTAgg( FigureCanvasQT, FigureCanvasAgg ): """ The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc... Public attribute figure - A Figure instance """ def __init__( self, figure ): if DEBUG: print 'FigureCanvasQtAgg: ', figure FigureCanvasQT.__init__( self, figure ) FigureCanvasAgg.__init__( self, figure ) self.drawRect = False self.rect = [] self.replot = True self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) def drawRectangle( self, rect ): self.rect = rect self.drawRect = True self.repaint( ) def paintEvent( self, e ): """ Draw to the Agg backend and then copy the image to the qt.drawable. In Qt, all drawing should be done inside of here when a widget is shown onscreen. """ #FigureCanvasQT.paintEvent( self, e ) if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \ self.get_width_height() # only replot data when needed if type(self.replot) is bool: # might be a bbox for blitting if self.replot: FigureCanvasAgg.draw(self) # matplotlib is in rgba byte order. QImage wants to put the bytes # into argb format and is in a 4 byte unsigned int. Little endian # system is LSB first and expects the bytes in reverse order # (bgra). if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian: stringBuffer = self.renderer._renderer.tostring_bgra() else: stringBuffer = self.renderer._renderer.tostring_argb() qImage = QtGui.QImage(stringBuffer, self.renderer.width, self.renderer.height, QtGui.QImage.Format_ARGB32) p = QtGui.QPainter(self) p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage)) # draw the zoom rectangle to the QPainter if self.drawRect: p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) ) p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )
Re: [Matplotlib-users] Colorbar embedding in qt4
Hello, You are using the TK backend. Add this at the top of your script: import matplotlib matplotlib.use('QT4Agg') from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar Should work. (Or at least will no more show errors related to TK backend...) Laurent -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Colorbar embedding in qt4
Hi alexander, I tryed yesterday to play a little with your script. I suspect that in fact each time you draw a figure, it is added to a pool of figure to be rendered. Thus it goes slower and slower. What I do in my scritpt is either update the datas or if the drawing is a completely new one (like a polar ionstaed of log previously) I delete the figure. To update data use: 1/self._plot, = axe.plot(x, y, 'b', animated=self._animated) Later: Loop: 2/self._plot.set_ydata(self._value) If you need to delete your figure (that is not your case, but who knows for the future): axe = fig.add_axes(self.getPosition()) self._fig.delaxes(self._axe) To go even faster(x10) you have the blitting method, but set_ydata should be sufficent. Laurent De : Alexander Hupfer [mailto:son...@gmail.com] Envoyé : jeudi 7 janvier 2010 03:36 Cc : matplotlib-users@lists.sourceforge.net Objet : Re: [Matplotlib-users] Colorbar embedding in qt4 I isolated the problem a bit more. For some reason drawing gets slower and slower with each plot drawn. from os import sys from time import time from PyQt4 import QtGui, QtCore import matplotlib matplotlib.use('QT4Agg') from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure class MyMplCanvas(FigureCanvas): """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" def __init__(self, parent=None, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) # We want the axes cleared every time plot() is called self.axes.hold(False) self.compute_initial_figure() # FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) def compute_initial_figure(self): pass class MyDynamicMplCanvas(MyMplCanvas): """A canvas that updates itself every second with a new plot.""" def __init__(self, *args, **kwargs): MyMplCanvas.__init__(self, *args, **kwargs) timer = QtCore.QTimer(self) QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), self.update_figure) timer.start(0) self.firstrun = True self.colorbar = None self.time = time() self.p = None def compute_initial_figure(self): pass def update_figure(self): self.p = self.axes.scatter([1,2,3],[4,5,6], c = range(3), animated=True) self.axes.set_xlabel('psi') self.axes.set_ylabel('delta') if self.firstrun == True: self.colorbar = self.axes.figure.colorbar(self.p) self.firstrun = False self.colorbar.set_clim(vmin=0,vmax=2) self.colorbar.draw_all() self.colorbar.set_label('time [abtr. ]') self.draw() newtime = time() print newtime - self.time self.time = newtime class ApplicationWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.main_widget = QtGui.QWidget(self) l = QtGui.QVBoxLayout(self.main_widget) dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100) l.addWidget(dc) self.main_widget.setFocus() self.setCentralWidget(self.main_widget) qApp = QtGui.QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("%s" % "Slow!") aw.setGeometry(100,100,800,600) aw.show() sys.exit(qApp.exec_()) On Mon, Jan 4, 2010 at 3:36 PM, Alexander Hupfer wrote: Ok, here is the code as a whole. I think it's still short enough to ilustrate the problem. Just start it with the datafile "elips" as an argument http://dl.dropbox.com/u/226980/elipsometry.tar.gz The timer shows how long each render cycle takes. The time seems to grow with number of cycles rendered even when no more points are added (the points are calculated with a continous rate in a background thread and are about 300 total). On Sun, Jan 3, 2010 at 8:16 PM, John Hunter wrote: On Sun, Jan 3, 2010 at 7:02 PM, Alexander Hupfer wrote: > Thanks I got it fixed. > This leads to the follow up question: > What is the right way to keep an application responsive while the graph is > drawn? > Drawing a scatter plot with 300 points seems to take a while. I guess I need > to launch the drawing in another thread but don't know exactly how to do > this and only find examples of doing calculations in the background and not > actual widget interaction. You posted some real code and a traceback, which helped move the ball forward. What we really need to see to help you though is a complete, free-standing example, that we can run on our machines, which exposes t
[Matplotlib-users] Problem with wxAgg toolbar and py2exe
Hello, I've recently used the toolbar from wxAgg backend: from matplotlib.backends.backend_wx import NavigationToolbar2Wx I've got a problem when trying to freeze my app now because I get this message when trying to invoke the toolbar: Traceback (most recent call last): File "CommandPanel.pyo", line 80, in OnOpenFile File "AnalystPanel.pyo", line 33, in addPanel File "Filter.pyo", line 50, in createWidget File "A1Filter.pyo", line 70, in fillWidget File "matplotlib\backends\backend_wx.pyo", line 1548, in __init__ File "matplotlib\backend_bases.pyo", line 1524, in __init__ File "matplotlib\backends\backend_wx.pyo", line 1570, in _init_toolbar File "matplotlib\backends\backend_wx.pyo", line 1405, in _load_bitmap IOError: Could not find bitmap file "mpl-data\images\home.png"; dying It is really strange because I've put this in my setup.py: import matplotlib data_files = matplotlib.get_py2exe_datafiles() So there is a directory mpl-data/images so should work. (other files are well found like fonts etc.) Any guys has had this issue? (Matplotlib 0.98.1) Laurent - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Colormap cluttering?
Hello, I would like to have a cluttering functionality to colorbar. http://en.wikipedia.org/wiki/Clutter_(radar) Before writing it, I would like to know if there is a way to doing it with matplotlib. What I mean by cluttering is: You've got a colormap associated with a graphic where value goes from 0 to 255 for example. Assigning a classical colormap (for example cm.jet) 0 value will be blue and 255 one will be red. What I need is a low clutter and max clutter, if I set low clutter to 10 and ax cluter to 250 then: Blue will be for value from 0 to 10 Then the colormap do his job from 10 to 250 and finally >From 250 to 255 colr will be set to max one = red. Is it ever done in matplotlib, if not what could be the strategy here.? I was thinking of set_over/set_under but seems not be exactly what I need because I want to recreate the colormap from 10 to 250 with N segments. (moreover I don't understand how you set the over/under value.) Laurent - 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] imshow update norm make my app crash.
Hi guys, continuing exploring matplotlib capabilities J I've applied the idea you've said later about colormap. Now I would like on an event to refresh my view so I've written this code: . def InitCode(self): . self.norm = plt.Normalize(vmin=0, vmax=255) self.cmap = cm.jet im_full = full_sonar.imshow( z, aspect= 'auto', cmap=self.cmap, norm=self.norm, interpolation='quadric') im_zoom = zoomed_sonar.imshow( z, aspect= 'auto',cmap=self.cmap, norm=self.norm, interpolation='quadric') self.fig.colorbar(im_full,cax=cax,orientation='vertical',extend='both') self.im_full = im_full self.im_zoom = im_zoom . def updateSonarView(self): self.im_full.set_cmap(self.cmap) self.im_zoom.set_cmap(self.cmap) self.im_full.set_norm(self.norm) self.im_zoom.set_norm(self.norm) self.fig.canvas.draw() def OnUpdateButton(self, event): self.low_clutter_val = self.clutter_low.GetPosition() self.high_clutter_val = self.clutter_high.GetPosition() self.norm = plt.Normalize(vmin=self.low_clutter_val, vmax=self.high_clutter_val) self.updateSonarView() But I get this error from the lib : Traceback (most recent call last): File "./Filters\A1Filter.py", line 183, in OnUpdateButton self.updateSonarView() File "./Filters\A1Filter.py", line 157, in updateSonarView self.im_full.set_norm(self.norm) File "C:\Python25\Lib\site-packages\matplotlib\cm.py", line 129, in set_norm self.changed() File "C:\Python25\Lib\site-packages\matplotlib\image.py", line 123, in changed cm.ScalarMappable.changed(self) File "C:\Python25\Lib\site-packages\matplotlib\cm.py", line 174, in changed self.callbacksSM.process('changed', self) File "C:\Python25\Lib\site-packages\matplotlib\cbook.py", line 152, in process func(*args, **kwargs) File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 1028, in on_changed cb.update_bruteforce(m) File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 649, in update_bruteforce self.draw_all() File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 221, in draw_all self._process_values() File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 458, in _process_values b = self.norm.inverse(self._uniform_y(self.cmap.N+1)) File "C:\Python25\Lib\site-packages\matplotlib\colors.py", line 652, in inverse return vmin + val * (vmax - vmin) File "C:\Python25\Lib\site-packages\numpy\ma\core.py", line 1686, in __mul__ return multiply(self, other) File "C:\Python25\Lib\site-packages\numpy\ma\core.py", line 503, in __call__ result = self.f(d1, d2, *args, **kwargs).view(get_masked_subclass(a,b)) ValueError: shape mismatch: objects cannot be broadcast to a single shape UpdateSonarview works flawlessly if I modify the colormap (self.cmap) and call it then. If I modify self.norm and call UpdateSonarView I get this crash. Is it a bug from my bad usage of the lib? If not, I can perhaps send you a stripped down file showing the problem? Using matplotlib 0.98.1 under windows. Laurent - 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] Problem with label displaying
Excellent! That's was EXACTLY what I needed! Thanks a lot Friedrich! :) 2008/9/20 Friedrich Hagedorn <[EMAIL PROTECTED]>: > On Sat, Sep 20, 2008 at 04:06:36PM +0200, Laurent Dufrechou wrote: >> Hello all, >> I'm trying to show to a friend matplotlib features via pylab interface. >> (thus to replace matlab/scilab) >> I've a little problem while I'm trying to display plots into subplots here >> under vista. >> If I add a pylab.xlabel to the subplots they are masked by the underlying >> subplot. >> To workaround it I need to change the window size. >> I used for myself add_axes([0.1,0.8,0.75,.15]) but that's not that easy. > > That's right (but sometimes I did the same :-) > >> Do I miss one important thing or must I go trought add_axes functions each >> time I call pylab.subplot? > > Yes, you can adjust the space between the subplot with > > subplots_adjust() > > Look at the docstring with > > In [1]: subplots-adjust? > > in ipython shell. Try to see the difference between > > figure() > subplot(211) > subplot(212) > show() > > and > > figure() > subplots_adjust(hspace=0.4) # standard: 0.2 > subplot(211) > subplot(212) > show() > > By, > > Friedrich > - 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] [PyQt] Pydee v0.3.0
Hey pierre, Wow that's fantastic! One week ago I started (not sent) a mail that was intended for you on python(x,y) I explained that the main issue I get with users I want to convert to python is: 1) "Hey there is so lot packages, each time I need to install a new package to get your feature." 2) "Python is bad for my dumb users, scilab is better, when they double click on the .sce it open the script, they edit the parameters in the script file and run the script clicking on run." Python(x,y) solved point 1. Pydee could solve point 2! Perhaps I will be able to trash these ## install of scilab! Have you planed to integrate it into python(x,y)? If yes, an excellent idea could be to be able to create file extension like .pyp that are python script but that open Pydee! Wow I had seen your pyqtshell I was really impressed by all the surrounding widgets. Wow ;) Good job! :) -- Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [wxpython-users] Controlling the wxpython matplotlib-frame
Have you tryied : ipython -pylab ? It launch an ipython shell that support mathplotlib gui loop. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] De la part de Wolfgang Kerzendorf Envoyé : mercredi 26 mars 2008 08:31 À : matplotlib-users@lists.sourceforge.net; [EMAIL PROTECTED] Objet : [wxpython-users] Controlling the wxpython matplotlib-frame Hello all, I have trouble with one of my scripts that uses matplotlib when using python or ipython. The first time it opens, it does not hand the control back o the shell and can be used to work on the matplotlib figure interactively (I use an event handler and picker objects to change my plots) so it works really well. After I close the window the control is given back to the shell. This is how I want it to work, however at the second time the matplotlib plot opens the shell does not stop anymore, the script continues. When I used GTKAgg on my old linux box I had the same issue and bound a key to pylab.get_current_figure_manager().destroy(), which looked like a hack to me but worked. This does not work anymore with wxPython, because the next time I open a plot I get an exception: PyDeadObjectError: The C++ part of the FigureFrameWxAgg object has been deleted, attribute access no longer allowed. I also think destroying the figure_manager is not the right way to do that. Whats a goog solution for this? Thanks in advance Wolfgang P.S.: I know I posted a similar thing yesterday, but I thought rephrasing the question might help with finding the solution ___ wxpython-users mailing list [EMAIL PROTECTED] http://lists.wxwidgets.org/mailman/listinfo/wxpython-users - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users