[Matplotlib-users] catching close figure event
Hello everybody, I would like to call a function when I close manually a window previously opened by a pylab.figure. I tried the following: f = pylab.figure() f.canvas.mpl_connect('close_event',my_function) but it fails because the 'close_event' is not recognized as a valid event (button_press_event, axis_leave_event ...). Would you have any idea ? thank you very much regards Eric Pellegrini -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] catching close figure event
Hi Ben, I use the version 0.99.3. Eric --- En date de : Jeu 29.7.10, Benjamin Root ben.r...@ou.edu a écrit : De: Benjamin Root ben.r...@ou.edu Objet: Re: [Matplotlib-users] catching close figure event À: Pellegrini Eric ericpellegr...@yahoo.fr Cc: matplotlib-users@lists.sourceforge.net Date: Jeudi 29 juillet 2010, 19h26 On Thu, Jul 29, 2010 at 12:18 PM, Pellegrini Eric ericpellegr...@yahoo.fr wrote: Hello everybody, I would like to call a function when I close manually a window previously opened by a pylab.figure. I tried the following: f = pylab.figure() f.canvas.mpl_connect('close_event',my_function) but it fails because the 'close_event' is not recognized as a valid event (button_press_event, axis_leave_event ...). Would you have any idea ? thank you very much regards Eric Pellegrini Eric, Which version of matplotlib are you using? close_event is a valid event identifier. Ben Root -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] catching close figure event
Hi Ryan, bad luck, I use the version 0.99.3 ... and currently I must keep on using it ... Would you see another way to proceed from matplotlib ? thanks Eric --- En date de : Jeu 29.7.10, Ryan May rma...@gmail.com a écrit : De: Ryan May rma...@gmail.com Objet: Re: [Matplotlib-users] catching close figure event À: Pellegrini Eric ericpellegr...@yahoo.fr Cc: Benjamin Root ben.r...@ou.edu, matplotlib-users@lists.sourceforge.net Date: Jeudi 29 juillet 2010, 19h29 On Thu, Jul 29, 2010 at 12:26 PM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Jul 29, 2010 at 12:18 PM, Pellegrini Eric ericpellegr...@yahoo.fr wrote: Hello everybody, I would like to call a function when I close manually a window previously opened by a pylab.figure. I tried the following: f = pylab.figure() f.canvas.mpl_connect('close_event',my_function) but it fails because the 'close_event' is not recognized as a valid event (button_press_event, axis_leave_event ...). Would you have any idea ? thank you very much Eric, Which version of matplotlib are you using? close_event is a valid event identifier. It was added in the most recent 1.0, so make sure you have that. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Redisplay a figure after it was closed
Hello everybody, My question is in the title ! Say that I have the following code: f = pylab.figure() f.plot([1,2,3,4,5]) pylab.show() and that, once I destroyed the figure by clicking on the top-right corner red button, I would like to redisplay it in the state it was just before I closed it. Is there way to do this ? There might be one as the variable f is still assigned as a figure object with all its attributes and methods still available. Thank you very much Eric -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] redraw a figure
Hello everybody, I have a question concerning the redrawing of one/several figures. Say that I have the following (very) simple code: ion() f1 = figure(1) plot([1,2,3,4]) f2 = figure(2) plot([1,1,1,1]) and that I killed f1 and f2 figures by clicking on their respective right-top corner. Is there a way to redisplay f1 and/or f2 in the state they were just before destroying them ? thank you very much for your help best regards Eric -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about gridlines
Dear all, When writing: f = figure() ... gl = f.gca().get_xgridlines() I always get a list of gridlines independantly of the fact that they are actually drawn or not. Is there an attribute or a method that could inform me whether the gridlines are actually displayed or not ? I thougt that the method get_visible could do the job but it seems to do an unrelated task. thank you very much Eric -- Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, Big Spaceship. http://p.sf.net/sfu/creativitycat-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Updating a plot
Hello everybody, I would like to create a plot from which I set the x data later. The method set_xdata works but the corresponding plot displays the initial x limits. Is it possible to update the plot automatically in order that the displayed plot has x limits corresponding to the newly set x data ? Here is the script that fails: import pylab fig = pylab.figure() ax = fig.add_subplot(111, label = 'plot1') p, = ax.plot([1,2,3,4,5]) p.set_xdata([10,20,30,40,50]) # ax.set_xlim([10,50]) fig.show() to update the xlim I have to add the commented line. thank you very much Eric Pellegrini -- This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Memory leak using matplotlib
Hi evebrybody, I started a discussion one week ago about a problem of memory leak using the following code: from Tkinter import * from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import pylab def display(): mat = pylab.zeros((100,100)) pylab.ioff() image = pylab.matshow(mat) pylab.ion() pylab.close() can = FigureCanvasTkAgg(image, master=frame) can.show() can.get_tk_widget().grid(row = 0,column = 0) root = Tk() frame = Frame(root) frame.grid(row = 0,column = 0) canvas = Canvas(frame, width = 240, height = 240, relief = sunken, bg = white) canvas.grid() button = Button(root,text=DisplayMatrix,command = display) button.grid(row = 1,column = 0) *** up to now, I have not found any way to solve it and unfortunately the proposed hints did not solve the problem (gc_collect(), clf(), cla()). Is there something new about this ? thanks Eric - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Memory leak with FigureCanvasTk
Hi, I have a problem of memory leak using the following code: from Tkinter import * from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import pylab def display(): mat = pylab.zeros((100,100)) pylab.ioff() image = pylab.matshow(mat) pylab.ion() pylab.close() can = FigureCanvasTkAgg(image, master=frame) can.show() can.get_tk_widget().grid(row = 0,column = 0) root = Tk() frame = Frame(root) frame.grid(row = 0,column = 0) canvas = Canvas(frame, width = 240, height = 240, relief = sunken, bg = white) canvas.grid() button = Button(root,text=DisplayMatrix,command = display) button.grid(row = 1,column = 0) *** would you have any idea of what is going wrong ? Thank you very much Eric - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about pylab.figure
Hi everybody, when repeating the following sequence: pylab.figure() pylab.close() the memory used increases like if something remained. Would you have any idea of what is going on ? How to solve this kind of memory leak ? thank you very much Eruc - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about matshow
Hi, I have some problems to combine a matshow object with a canvas. Here is a little piece of code that illustrates my problem. It displays a matshow object when pressing a button. I would like to embed the matshow object into a canvas of a fixed dimension. The code I wrote does the opposite i.e. it is the canvas that adapts its size and not the matshow object. Would you have any hints ? ** from Tkinter import * from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import pylab def display(): mat = pylab.zeros((100,100)) pylab.ioff() image = pylab.matshow(mat) pylab.ion() can = FigureCanvasTkAgg(image, master=frame) can.show() can.get_tk_widget().grid(row = 0,column = 0) root = Tk() frame = Frame(root) frame.grid(row = 0,column = 0) canvas = Canvas(frame, width = 240, height = 240, relief = sunken, bg = white) canvas.grid() button = Button(root,text=DisplayMatrix,command = display) button.grid(row = 1,column = 0) Thank you very much Eric - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Problem to embed figure in Tk
Hi everybody, Would you have any idea how to embed a matshow (or imshow) object in a Tk application but with a given dimension ? Using FigureCanvasTkAgg embed a matshow object in my application but it takes the dimension of the matshow object not the dimension of the place where I would like to embed it. Thank you very much Best regards Eric Pellegrini - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about imshow and matshow
Hello everybody, when using matplotlib, any plot I create is displayed separately from my Tkinter application. Is there a direct way to embed the plot created by matplotlib in a widget such as a canvas using something like create_image or something else ? Currently, the only thing I managed to do is: -create my plot with matshow -save the figure using savefig (png) -embed the png in a canvas using create_image not very smart, isn't it ? Thank you very much best regards Eric Pellegrini - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RE : Re: Problem with pylab.fill
Hi John, thank you very much for the hand. I think that I have found my mistake. I was launching my script trough Idle that seems to be the reason why it was to slow. Running my script with the command line or by double-clicking on it gave results similar to yours. Would you know why Idle application slows down so much the execution of my script ? By the way, using the Collection class, would you have any idea how to set different colors to the polygons ? Using set_color method change the color of all the plygons. Thanks again Eric John Hunter [EMAIL PROTECTED] a écrit : Pellegrini == Pellegrini Eric writes: Pellegrini Hi everybody, I would like to build an application Pellegrini where many filled polygons will have to be displayed Pellegrini on the screen. To do so, I would like to use Pellegrini matplotlib but, up to now, my application is not fast Pellegrini enough. Hmm, I'm not seeing the performance problem on my system -- I can create and save the figure in a fraction of a second. Is your numerix setting set to numpy? Run the script with --verbose-helpful and send us the output. A few things to note: if you really want regular polygons, eg the squared in your example, do any of the plot markers work for you. plot(x, marker='s') will be about as fast as mpl gets. You can set the marker size with the markersize property. Second, if you need arbitrary polygons, and need a lot of them, a polygon collection will be faster. I had to bump the number of polys up to about 8000 to show a dramatic performance difference. Here are two scripts and performance numbers -- one using fill and one using a polygon collection time python test.py -dAgg 6.595u 0.089s 0:06.68 99.8% 0+0k 0+0io 0pf+0w time python test2.py -dAgg 0.565u 0.033s 0:00.59 100.0% 0+0k 0+0io 0pf+0w cat test.py import pylab x = range(0,81000,10) pylab.axis('off') for i in range(0,len(x)-1): pylab.fill([x[i],x[i+1],x[i+1],x[i]],[10,10,20,20]) pylab.axis((0,max(x),0,610)) pylab.savefig('test') pylab.show() cat test2.py import pylab from matplotlib.collections import PolyCollection fig = pylab.figure() ax = fig.add_subplot(111) x = range(0,81000,10) pylab.axis('off') verts = [((x[i], 10), (x[i+1], 10), (x[i+1], 20), (x[i], 20)) for i in range(len(x)-1)] col = PolyCollection(verts) ax.add_collection(col) pylab.axis((0,max(x),0,610)) pylab.savefig('test') pylab.show() - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RE : Re: Problem with pylab.fill
I forgot to send the output of the python test.py --verbose-helpful. Perhaps you will find something wrong there. Here it is: matplotlib data path C:\Python24\lib\site-packages\matplotlib\mpl-data $HOME=C:\Documents and Settings\Eric CONFIGDIR=C:\Documents and Settings\Eric\.matplotlib loaded rc file C:\Python24\lib\site-packages\matplotlib\mpl-data\matplotlibrc matplotlib version 0.87.6 verbose.level helpful interactive is False platform is win32 numerix numpy 1.0rc1 font search path ['C:\\Python24\\lib\\site-packages\\matplotlib\\mpl-data'] loaded ttfcache file C:\Documents and Settings\Eric\.matplotlib\ttffont.cache backend TkAgg version 8.4 Thanks again Eric John Hunter [EMAIL PROTECTED] a écrit : Pellegrini == Pellegrini Eric writes: Pellegrini Hi everybody, I would like to build an application Pellegrini where many filled polygons will have to be displayed Pellegrini on the screen. To do so, I would like to use Pellegrini matplotlib but, up to now, my application is not fast Pellegrini enough. Hmm, I'm not seeing the performance problem on my system -- I can create and save the figure in a fraction of a second. Is your numerix setting set to numpy? Run the script with --verbose-helpful and send us the output. A few things to note: if you really want regular polygons, eg the squared in your example, do any of the plot markers work for you. plot(x, marker='s') will be about as fast as mpl gets. You can set the marker size with the markersize property. Second, if you need arbitrary polygons, and need a lot of them, a polygon collection will be faster. I had to bump the number of polys up to about 8000 to show a dramatic performance difference. Here are two scripts and performance numbers -- one using fill and one using a polygon collection time python test.py -dAgg 6.595u 0.089s 0:06.68 99.8% 0+0k 0+0io 0pf+0w time python test2.py -dAgg 0.565u 0.033s 0:00.59 100.0% 0+0k 0+0io 0pf+0w cat test.py import pylab x = range(0,81000,10) pylab.axis('off') for i in range(0,len(x)-1): pylab.fill([x[i],x[i+1],x[i+1],x[i]],[10,10,20,20]) pylab.axis((0,max(x),0,610)) pylab.savefig('test') pylab.show() cat test2.py import pylab from matplotlib.collections import PolyCollection fig = pylab.figure() ax = fig.add_subplot(111) x = range(0,81000,10) pylab.axis('off') verts = [((x[i], 10), (x[i+1], 10), (x[i+1], 20), (x[i], 20)) for i in range(len(x)-1)] col = PolyCollection(verts) ax.add_collection(col) pylab.axis((0,max(x),0,610)) pylab.savefig('test') pylab.show() - Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users