Re: [Matplotlib-users] 2 overlaid plots with grid??
I seem to recall that the MaxNLocator and some carefully chosen axes limits suffices for me in the past. On Tue, Oct 21, 2014 at 11:44 AM, Adam Hughes hughesada...@gmail.com wrote: I wrote a program that draws grids manually on mpl plots a while back. If you can't find a solution can you write back here and I'll try to get that dusted off? On Oct 21, 2014 2:39 PM, Benjamin Root ben.r...@ou.edu wrote: Well, the first part is easy... it is called twinx(). If you look up axis twinning in the documentation, you will find a lot of examples of this. As for the grids part... that would be tricky. I would first just see if matplotlib just does the right thing. Doubtful, but who knows? Then I would likely go the route of lining up the major ticks on both axes so that the grid lines for one axes match up with the ticks for the other. Let us know what you find out. Maybe it might be a useful feature to add for twinning. Cheers! Ben Root On Tue, Oct 21, 2014 at 2:29 PM, Neal Becker ndbeck...@gmail.com wrote: I need to overlay 2 different plots. They will share an x-axis, but will have 2 different y axis with 2 different sets of units. I want one y-axis on left and one on right. But to make it harder, I want a grid. That means, there are either 2 different grids, which is ugly, or one plot has to be scaled vertically so that the same y grid can be shared between them. Anyone know how to do this? -- -- Those who don't understand recursion are doomed to repeat it -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] avoid duplicate legends
I was able to solve my two problems by doing label= and numpoints=1. Thank you very much for your help. I found my solution here: http://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib There is also another cleaner solution here: http://stackoverflow.com/questions/13588920/stop-matplotlib-repeating-labels-in-legend import matplotlib matplotlib.use('Agg') from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt map = Basemap() map.plot(label=) plt.legend(numpoints=1) On Mon, Oct 20, 2014 at 8:11 AM, Benjamin Root ben.r...@ou.edu wrote: Legends entries are blindly constructed. Each plotting call that has a legend keyword argument will produce a legend entry if you are automatically building the legend. You can pass a label value of __nolabel__ to prevent an entry if you know you are about to do something that would duplicate the entries. Another approach is to manually collect unique artists and manually build the legend (I think there is an example of that in the gallary). As for configuring the legend, there are a bunch of parameters that can be set for sizing the font. I think the sizing of the marker is determined by their size in the plot, though. Cheers! Ben Root On Mon, Oct 20, 2014 at 10:46 AM, Hearne, Mike mhea...@usgs.gov wrote: For your first question: Use the legend numpoints keyword. I think if you set it to 1, it should solve that problem. For your second question, I'm not sure, but I'll bet if you poke around in the Legend object returned by the function, you'll find something. On Mon, Oct 20, 2014 at 8:04 AM, Tommy Carstensen tommy.carsten...@gmail.com wrote: How does one avoid duplicate legends? www.tommycarstensen.com/python2_matplotlib_basemap_merc_bluemarble_hresolution.jpg Can I make the legend size smaller than the marker size? -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] memory leak on MacOS with TkAgg
I'm seeing a memory leak with calls to subplot.clear() and canvas.draw() on MacOS. The same code shows no leakage on unix. Here is a simple script that demonstrates the problem. #!/usr/bin/env python from __future__ import division Demonstrate a memory leak in matplotlib on MacOS with TkAgg Variants: - Comment out subplot.clear(): this reduces the leak by about 4/5 - Comment out canvas.draw(): this reduces the leak by about 1/5 - Comment out both: there should be essentially no leakage The leak rate seems to be affected by the update rate (larger update interval causes lower leakage), which suggests it's not a simple x amount of leakage per call. import resource import time import Tkinter import matplotlib from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg class MemoryLeaker(Tkinter.Frame): Demonstrate a memory leak in matplotlib def __init__(self, master, updateInterval=0.1, updatesPerReport=25): Construct a MemoryLeaker Inputs: - master: master widget - updateInterval: interval at which subplot.clear and canvas.draw are called - updatesPerReport: number of updates between memory reports Tkinter.Frame.__init__(self, master) self._updateInterval = float(updateInterval) self._updatesPerReport = int(updatesPerReport) self.figure = matplotlib.figure.Figure(figsize=(8, 2), frameon=True) self.canvas = FigureCanvasTkAgg(self.figure, self) self.canvas.get_tk_widget().grid(row=0, column=0, sticky=news) self.subplot = self.figure.add_subplot(1, 1, 1) print time max RSSleak rate print (sec) (kb) (kb/sec) self._prevTime = time.time() self._prevMem = float(nan) self._reportCount = 0 self.updatePlot() def updatePlot(self): Update the plot; calls itself at the update interval if self._reportCount == 0: self.reportMem() self._reportCount = (self._reportCount + 1) % self._updatesPerReport self.subplot.clear() self.canvas.draw() self.after(int(self._updateInterval * 1000), self.updatePlot) def reportMem(self): currTime = time.time() dTime = currTime - self._prevTime res = resource.getrusage(resource.RUSAGE_SELF) currMem = res.ru_maxrss / 1024 # maximum resident set size utilized (in kb) leakRate = (currMem - self._prevMem) / dTime self._prevTime = currTime self._prevMem = currMem print %6.1f %6d%6.1f % (dTime, currMem, leakRate) if __name__ == __main__: root = Tkinter.Tk() wdg = MemoryLeaker(root, updateInterval=0.1, updatesPerReport=25) wdg.pack(expand=True, fill=both) root.mainloop() P.S. my current setup is: - MacOS 10.9 - python.org python 2.7.8 - matploblib 1.3.1 - a pre-release of Tcl/Tk 8.5.17 but I've seen this on many earlier versions, as well I have not tried it with matplotlib 1.4.1 yet (due to problems packaging that with py2app). -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users