Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
Thank you, Sorry I did known the existence of matplotlib.backends.backend_qt4agg. It is more easy than I thought. but I still have a problem. This is my code : import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure #-- class MyWidget(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.menuBar = QMenuBar() self.fileMenu = QMenu(self.tr("&File"), self) self.menuBar.addMenu(self.fileMenu) mainLayout = QVBoxLayout() mainLayout.setMenuBar(self.menuBar) self.setLayout(mainLayout) #-- if __name__ == "__main__": app = QApplication(sys.argv) dialog = MyWidget() dialog.show() sys.exit(app.exec_()) and it does not works because the main window is blocking. But when I comment this line : #from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas it works ! What am I doing wrong ? PyQT4 is 4.0.1 Matplotlib is 0.87.4 Samuel Darren Dale wrote: On Tuesday 15 August 2006 16:05, [EMAIL PROTECTED] wrote: Thank you very much. What I would like is example for embedding_in_qt.py but whith qt4 when I tried : import PyQt4 from PyQt4.QtCore import * from PyQt4.QtGui import * from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure but I have : Traceback (most recent call last): You should be doing this instead: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas Darren - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
On Wednesday 16 August 2006 04:54, Samuel GARCIA wrote: > I still have a problem. This is my code : > > import sys > > from PyQt4.QtCore import * > from PyQt4.QtGui import * > > from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as > FigureCanvas > from matplotlib.figure import Figure > > #-- > class MyWidget(QWidget): > def __init__(self, parent=None): > QWidget.__init__(self, parent) > self.menuBar = QMenuBar() > self.fileMenu = QMenu(self.tr("&File"), self) > self.menuBar.addMenu(self.fileMenu) > > mainLayout = QVBoxLayout() > mainLayout.setMenuBar(self.menuBar) > > self.setLayout(mainLayout) > > #-- > if __name__ == "__main__": > app = QApplication(sys.argv) > dialog = MyWidget() > dialog.show() > sys.exit(app.exec_()) > > and it does not works because the main window is blocking. > But when I comment this line : > #from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as > FigureCanvas > it works ! > What am I doing wrong ? You may not be doing anything wrong. The qt4 backend is new and hasn't seen much use. I think you are the first to try to embed in your own qt4 application. If you feel up to it, maybe you could try to track down the problem. Darren - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend outside plot
On Wednesday 16 August 2006 02:26, Brendan Barnwell wrote: > Hi, I'm trying to get matplotlib to give me a plot where the legend is > outside the axes. > > I saw several posts about this in the mailing list archives, but none of > them really seem to provide workable solutions. Try passing the loc kwarg to legend(). Like legend([...], loc=(1.01, 0.25)) > Or, alternatively, is there some easier way to get legends to NEVER > overlap lines? try legend([...], loc='best') Darren - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
I am not good enougth track and solve the problem. Maybe I can be a beta tester. I saw in svn that the author of qt4 backend is Charlie Moad. And it is very young (6 weeks). So a question for Charlie moad : do you have a example which could work on my debian unstable station for embedding_in_qt4.py ? thank you Samuel Darren Dale wrote: On Wednesday 16 August 2006 04:54, Samuel GARCIA wrote: I still have a problem. This is my code : import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure #-- class MyWidget(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.menuBar = QMenuBar() self.fileMenu = QMenu(self.tr("&File"), self) self.menuBar.addMenu(self.fileMenu) mainLayout = QVBoxLayout() mainLayout.setMenuBar(self.menuBar) self.setLayout(mainLayout) #-- if __name__ == "__main__": app = QApplication(sys.argv) dialog = MyWidget() dialog.show() sys.exit(app.exec_()) and it does not works because the main window is blocking. But when I comment this line : #from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas it works ! What am I doing wrong ? You may not be doing anything wrong. The qt4 backend is new and hasn't seen much use. I think you are the first to try to embed in your own qt4 application. If you feel up to it, maybe you could try to track down the problem. Darren - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
On Wednesday 16 August 2006 08:49, Samuel GARCIA wrote: > I am not good enougth track and solve the problem. > Maybe I can be a beta tester. > > I saw in svn that the author of qt4 backend is Charlie Moad. > And it is very young (6 weeks). I think you misread the svn entry. James Amundson ported the qt3 backend to qt4, but it was not quite finished. I finished the port and committed it. Charlie added blitting. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
I am not the author of it. I just may of made the last commits to it. I am pretty sure Darren wrote the initial implimentatin. The only example that exists right now is animation_blit_qt4.py. On 8/16/06, Samuel GARCIA <[EMAIL PROTECTED]> wrote: > > I am not good enougth track and solve the problem. > Maybe I can be a beta tester. > > I saw in svn that the author of qt4 backend is Charlie Moad. > And it is very young (6 weeks). > > So a question for Charlie moad : do you have a example which could work on > my debian unstable station for embedding_in_qt4.py ? > > thank you > > Samuel > > > > Darren Dale wrote: > On Wednesday 16 August 2006 04:54, Samuel GARCIA wrote: > > > I still have a problem. This is my code : > > import sys > > from PyQt4.QtCore import * > from PyQt4.QtGui import * > > from matplotlib.backends.backend_qt4agg import > FigureCanvasQTAgg as > FigureCanvas > from matplotlib.figure import Figure > > #-- > class MyWidget(QWidget): > def __init__(self, parent=None): > QWidget.__init__(self, parent) > self.menuBar = QMenuBar() > self.fileMenu = QMenu(self.tr("&File"), self) > self.menuBar.addMenu(self.fileMenu) > > mainLayout = QVBoxLayout() > mainLayout.setMenuBar(self.menuBar) > > self.setLayout(mainLayout) > > #-- > if __name__ == "__main__": > app = QApplication(sys.argv) > dialog = MyWidget() > dialog.show() > sys.exit(app.exec_()) > > and it does not works because the main window is blocking. > But when I comment this line : > #from matplotlib.backends.backend_qt4agg import > FigureCanvasQTAgg as > FigureCanvas > it works ! > What am I doing wrong ? > > You may not be doing anything wrong. The qt4 backend is new and hasn't seen > much use. I think you are the first to try to embed in your own qt4 > application. If you feel up to it, maybe you could try to track down the > problem. > > Darren > > > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is matplotlib compatible whith PyQt4 ?
Sorry for the mistake. Darren Dale wrote: On Wednesday 16 August 2006 08:49, Samuel GARCIA wrote: I am not good enougth track and solve the problem. Maybe I can be a beta tester. I saw in svn that the author of qt4 backend is Charlie Moad. And it is very young (6 weeks). I think you misread the svn entry. James Amundson ported the qt3 backend to qt4, but it was not quite finished. I finished the port and committed it. Charlie added blitting. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Agg backend writing to StringIO?
> Nelson Minar <[EMAIL PROTECTED]> writes: > > > matplotlib is great, particularly the image quality. I'm using > > matplotlib to generate images in a webapp and have run into a problem. > > How do I get it to give me the rendered image bytes in a string rather > > than writing the image to a file? > > FigureCanvasAgg has the undocumented methods buffer_rgba, > tostring_argb, and tostring_rgb, which might help here. > > > The docs for FigureCanvasAgg.print_figure() says that if the filename > > is actually a file object then it will write the bytes to that file > > object. This works great if I pass in sys.stdout, but as soon as I try > > to use a StringIO() instance to capture the bytes in Python I get an > > error: > [...] > > TypeError: Could not convert object to file pointer > > libpng seems to require an actual file pointer. This was discussed in > http://thread.gmane.org/gmane.comp.python.matplotlib.general/3118/ libpng does not require a file pointer. It can write to streams (or StringIO objects) too. Cairo uses libpng to write to streams, and PyCairo uses cairo (and libpng) to write to file-like objects (like StringIO), so it is possible. But I don't know the details, the technique is buried somewhere in the cairo and libpng C code. Steve Send instant messages to your online friends http://au.messenger.yahoo.com - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Agg backend writing to StringIO?
Thanks for the answers. I was glad to see Steven Chaplin suggest that it is possible to get libpng to write directly to a stream like StringIO; seems like a good thing. In the meantime I came up with the following little helper functions to render a Figure to PNG (via Agg) or SVG (via SVG). def getPngFromFigure(figure, imageSize): canvas = FigureCanvasAgg(figure) canvas.draw() imageSize = canvas.get_width_height() imageRgb = canvas.tostring_rgb() pilImage = PIL.Image.fromstring("RGB", imageSize, imageRgb) buffer = StringIO.StringIO() pilImage.save(buffer, "PNG") return buffer.getvalue() def getSvgFromFigure(figure, imageSize): canvas = FigureCanvasSVG(figure) canvas.draw() svgwriter = StringIO.StringIO() renderer = RendererSVG(imageSize[0], imageSize[1], svgwriter) figure.draw(renderer) renderer.finish() return svgwriter.getvalue() This code works, and while I don't really understand matplotlib internals I think I'm mostly doing things right. Two minor problems: The Agg images are RGB, no alpha channel. Amusingly enough Agg gives you ARGB but PIL only understands RGBA. My code is ignoring whatever size the Figure itself thinks it should be. Jouni K Seppanen wrote: Nelson Minar <[EMAIL PROTECTED]> writes: matplotlib is great, particularly the image quality. I'm using matplotlib to generate images in a webapp and have run into a problem. How do I get it to give me the rendered image bytes in a string rather than writing the image to a file? FigureCanvasAgg has the undocumented methods buffer_rgba, tostring_argb, and tostring_rgb, which might help here. The docs for FigureCanvasAgg.print_figure() says that if the filename is actually a file object then it will write the bytes to that file object. This works great if I pass in sys.stdout, but as soon as I try to use a StringIO() instance to capture the bytes in Python I get an error: [...] TypeError: Could not convert object to file pointer libpng seems to require an actual file pointer. This was discussed in http://thread.gmane.org/gmane.comp.python.matplotlib.general/3118/ - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users