[Matplotlib-users] Changing size of legends with multiple plots
Hi! I'm trying to do a few plots in one figure using subplot, but the size of the legends isn't changing as I try to add more plots. I have found out how to change the size the hard-coded way, but is there any way I can get the legend to know how large it should be? For example, with the following test code the legend is fine with 2 rows of figures, but massive for 5 rows: y=([ 1.2, 2.3, 3.4, 2.2 ]) z=([ 2.2, 2.6, 1.4, 1.2 ]) a1=subplot(541) plot( y, label='TESTY' ) a1.legend() a2=subplot(542) plot( z, label='TESTZ' ) a2.legend() show() Thanks for any tips, Dave ~ - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Iterate and save multiple plots
Dear all, I have a list with about 300 elements like the following: listNames = ['name1', 'name2', 'name3', ...] I want to iterate through this list, creating several figures where each one will include two subplots. The problem is that I want to label each figure like in the following example: 'name1_name2.png' How do I concatenate those names in the savefig() function? Thanks, Ana - 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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=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
Ana Paula Leite wrote: > Dear all, > > I have a list with about 300 elements like the following: > listNames = ['name1', 'name2', 'name3', ...] > > I want to iterate through this list, creating several figures where each > one will include two subplots. > The problem is that I want to label each figure like in the following > example: > > 'name1_name2.png' > > How do I concatenate those names in the savefig() function? > How about name = "%s_%s.png" %(listNames[0], listNames[1]) savegig(name) or name = listNames[0] + "_" + listNames[1] + ".png" -- cheers, steve Random number generation is the art of producing pure gibberish as quickly as possible. - 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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] cumulative distribution function
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? On Mar 18, 2007, at 12:41 PM, John Hunter wrote: > On 3/17/07, Simson Garfinkel <[EMAIL PROTECTED]> wrote: >> Hi. I haven't been active for a while, but now I have another paper >> that I need to get out... > > Glad to have you back... > >> Anyway, I need to draw a cumulative distribution function, as the >> reviewers of my last paper really nailed me to the wall for including >> histograms instead of CDFs. Is there any way to plot a CDF with >> matplotlib? > > For analytic cdfs, see scipy.stats. I assume you need an empirical > cdf. You can use matplotlib.mlab.hist to compute the empirical pdf > (use normed=True to return a PDF rather than a frequency count). Then > use numpy.cumsum to do the cumulative sum of the pdf, multiplying by > the binsize so it approximates the integral. > > import matplotlib.mlab > from pylab import figure, show, nx > > x = nx.mlab.randn(1) > p,bins = matplotlib.mlab.hist(x, 50, normed=True) > db = bins[1]-bins[0] > cdf = nx.cumsum(p*db) > > fig = figure() > ax = fig.add_subplot(111) > ax.bar(bins, cdf, width=0.8*db) > show() > - 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.php&p=sourceforge&CID=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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] cumulative distribution function
Hi Simson, On Wednesday 21 March 2007 02:59, Simson Garfinkel 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? Try this one: x = sin(arange(0,100,0.1)) ## your function ## plot the sorted value of your function against ## a linear vektor from 0 to 1 with the same length plot(sort(x), arange(len(x))/float(len(x))) Regrads Werner - 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.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users