[Matplotlib-users] subplots with the OO interface (ax.rowNum, ax.colNum)
I have a figure with 2 subplots (2 rows, 1 column) created using the OO interface like this: ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) After I have created these axes and plotted things on them, I want to be able to set their x and y lims. The function that creates the plot returns fig. I can then get to a list of the axes from fig.axes. My question is this: can I know from the list of axes or their individual properties which one is which - i.e. which one is the top one and which one is the bottom one? It looks like ax1.rowNum and colNum should refer to the parameters I want (rowNum in this case, since there is only one column). But there isn't a docstring for them. Is this there intended use (or at least a safe use of them)? 99% of the time, I will create the top one first so topfig=fig.axes[0] and bottomfig=fig.axes[1]. But if I ever screw that up, it could be bad. Thanks, Ryan - 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
Re: [Matplotlib-users] subplots with the OO interface (ax.rowNum, ax.colNum)
On 3/20/07, Ryan Krauss [EMAIL PROTECTED] wrote: I have a figure with 2 subplots (2 rows, 1 column) created using the OO interface like this: ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) After I have created these axes and plotted things on them, I want to be able to set their x and y lims. The function that creates the plot returns fig. I can then get to a list of the axes from fig.axes. My question is this: can I know from the list of axes or their individual properties which one is which - i.e. which one is the top one and which one is the bottom one? It looks like ax1.rowNum and colNum should refer to the parameters I want (rowNum in this case, since there is only one column). But there isn't a docstring for them. Is this there intended use (or at least a safe use of them)? 99% of the time, I will create the top one first so topfig=fig.axes[0] and bottomfig=fig.axes[1]. But if I ever screw that up, it could be bad. If you are creating subplots, you can do rows, cols, num = ax.get_geometry() You can also change the geometry with set_geometry. There are a couple of Subplot helper functions you may find useful, eg to selectively apply x and ylabeling: def is_first_col(self): return self.colNum==0 def is_first_row(self): return self.rowNum==0 def is_last_row(self): return self.rowNum==self.numRows-1 def is_last_col(self): return self.colNum==self.numCols-1 - 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
Re: [Matplotlib-users] subplots with the OO interface (ax.rowNum, ax.colNum)
Thanks John. That will work. Ryan On 3/20/07, John Hunter [EMAIL PROTECTED] wrote: On 3/20/07, Ryan Krauss [EMAIL PROTECTED] wrote: I have a figure with 2 subplots (2 rows, 1 column) created using the OO interface like this: ax1=fig.add_subplot(2,1,1) ax2=fig.add_subplot(2,1,2) After I have created these axes and plotted things on them, I want to be able to set their x and y lims. The function that creates the plot returns fig. I can then get to a list of the axes from fig.axes. My question is this: can I know from the list of axes or their individual properties which one is which - i.e. which one is the top one and which one is the bottom one? It looks like ax1.rowNum and colNum should refer to the parameters I want (rowNum in this case, since there is only one column). But there isn't a docstring for them. Is this there intended use (or at least a safe use of them)? 99% of the time, I will create the top one first so topfig=fig.axes[0] and bottomfig=fig.axes[1]. But if I ever screw that up, it could be bad. If you are creating subplots, you can do rows, cols, num = ax.get_geometry() You can also change the geometry with set_geometry. There are a couple of Subplot helper functions you may find useful, eg to selectively apply x and ylabeling: def is_first_col(self): return self.colNum==0 def is_first_row(self): return self.rowNum==0 def is_last_row(self): return self.rowNum==self.numRows-1 def is_last_col(self): return self.colNum==self.numCols-1 - 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
Re: [Matplotlib-users] Iterate and save multiple plots
It's just as simple as: savefig('name1'+'_'+'name2') - 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
Re: [Matplotlib-users] Question about pylab.figure
Pellegrini Eric wrote: 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 ? I have confirmed this with svn on linux (default backend, GtkAgg) using the attached script. We are losing about 17k per loop. The usual memory leak checker still indicates that things are OK. The difference appears to be the backend. The attached script with Agg instead of GtkAgg is OK; but with TkAgg it also leaks. It looks like there is something in the interactive backend setup that is not getting cleaned up by close(). Thanks for pointing it out. Eric #!/usr/bin/env python import os, sys, time import matplotlib #matplotlib.interactive(True) #matplotlib.use('Cairo') matplotlib.use('TkAgg') import pylab def report_memory(i): pid = os.getpid() a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines() print i, ' ', a2[1], return int(a2[1].split()[1]) # take a memory snapshot on indStart and compare it with indEnd indStart, indEnd = 30, 201 for i in range(indEnd): pylab.figure() pylab.close() val = report_memory(i) if i==indStart: start = val # wait a few cycles for memory usage to stabilize end = val print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)) Average memory consumed per loop: 0.0053k bytes - 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
Re: [Matplotlib-users] cumulative distribution function
On 3/20/07, Simson Garfinkel [EMAIL PROTECTED] wrote: Thanks for the information. Unfortunately, this CDF doesn't look like the CDF that we see in other published papers. I'm not sure what they are done with... But they have a thin line that shows the integral of all measurements, rather than a bar graph. The problem with a bar graph is that different bin widths give different results. GNU Plot seems to do a decent job, as can e seen at http:// chem.skku.ac.kr/~wkpark/tutor/gnuplot/gpdocs/prob.htm. But there should be a way to do this nicely with matplotlib, right? Just replace ax.bar(bins, p) with ax.plot(bins, b) in the example code I posted previously... JDH - 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