Re: [Matplotlib-users] Memory leakage in matplotlib 1.0.1 with wx 2.8.11.0

2011-04-27 Thread Oren Gampel
Thanks, Mike, for responding to my question!

I've pulled the latest HEAD from github (1.1.0) and test it withe the latest
wx (2.8.12 from few days ago) and added your patch from pull 89. I'm afraid
the leak is still the same. I also tried to use "your" version from github,
which already has the patch, but it didn't effect the leak. The problem
occures on all PCs I checked, some with winXP and one or two running Win7
OS.

I was somewhat inaccurate in a previous email. I did add a single axes to
the original script in the line:
self._price_ax = self.fig.add_subplot(111)
But now replaced it with the line:
self.fig.add_axes([0.075,0.1,0.75,0.85])
from the original script and the problem remains. Basically redrawing a
canvas with a single axes and nothing more on it grows the memory by more
than 100k per second.

Any ideas on what else can I check? workaround?

I'll appreciate it if anyone else can try and reproduce it.

Oren


 Re: [Matplotlib-users] Memory leakage in matplotlib 1.0.1 with wx 2.8.11.0
>
> Michael Droettboom
> Thu, 21 Apr 2011 09:58:10 -0700
>  The repository is now on github, so if you want the very latest, you should
> get it from here:
>
> https://github.com/matplotlib/matplotlib
>
> (We haven't done a terribly good job of advertising that change).
>
> I'm not seeing any leak myself with your script with matplotlib HEAD plus
> this pull request:
>
> https://github.com/matplotlib/matplotlib/pull/89
>
> so we may be getting to the bottom of this type of leak.
>
> Mike
>
> On 04/20/2011 05:18 PM, Oren Gampel wrote:
>
> I have now tested this with version 1.1.0svn from the trunk of the dev 
> repository.
> I believe this version contains Michael Droettboo's patch for pyCXX. (
> https://sourceforge.net/tracker/index.php?func=detail&aid=3115633&group_id=3180&atid=103180
> <
> https://sourceforge.net/tracker/index.php?func=detail&aid=3115633&group_id=3180&atid=103180>
> ) Unfortunately the leak is still evident in the small script I've attached.
> Again, please note that this script has no axes, plots, or drawn
> components, only an empty canvas that is being redrawn and causes the
> memory growth.
>
> Any ideas how to resolve this or further debug this?
>
> Thanks for your help,
> Oren
>
> On Mon, Apr 11, 2011 at 6:37 PM, Oren Gampel  mailto:o...@futuretech.co.il >> wrote:
>
> I'm having a memory leakage using matplotlib 1.0.1 with wx
> 2.8.11.0, on windows XP.
>
> To reproduce, I used the sample from here:
>
> http://matplotlib.sourceforge.net/examples/animation/dynamic_image_wxagg2.html
> and deleted most of the significant lines (see below). I only
> create a canvas but I don't create any axes, nor plot any data.
> The only thing I do is draw() on a timer event. This makes my
> process grow about 6Mbyte per minute.
>
> Is this reproduced in other environments? Any ideas on how to
> resolve this?
>
> Thanks,
> Oren
>
>
> """
> Copyright (C) 2003-2005 Jeremy O'Donoghue and others
>
> License: This work is licensed under the PSF. A copy should be
> included
> with this source code, and is also available at
> http://www.python.org/psf/license.html
>
> """
> import sys, time, os, gc
>
> import matplotlib
> matplotlib.use('WXAgg')
>
> from matplotlib import rcParams
> import numpy as npy
>
> import matplotlib.cm  as cm
>
> from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
> from matplotlib.backends.backend_wx import NavigationToolbar2Wx
>
> from matplotlib.figure import Figure
> from wx import *
>
>
> TIMER_ID = NewId()
>
> class PlotFigure(Frame):
>
> def __init__(self):
> Frame.__init__(self, None, -1, "Test embedded wxFigure")
>
> self.fig = Figure((1,1), 50, facecolor='.95')
> self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
> # Now put all into a sizer
> sizer = wx.BoxSizer(wx.VERTICAL)
> # This way of adding to sizer allows resizing
> sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
> self.SetSizer(sizer)
> self.Fit()
>
> self._price_ax = self.fig.add_subplot(111)
>
>
> wx.EVT_TIMER(self, TIMER_ID, self.onTimer)
> self.t = wx.Timer(self, TIMER_ID)
> self.t.Start(1000)
>
> def onTimer(self, evt):
> self.canvas.draw()
>
>
> if __name__ == '__main__':
> app = PySimpleApp()
> frame = PlotFigure()
> # Initialise the timer - wxPython requires this to be connected to
> # the receiving event handler
> t = Timer(frame, TIMER_ID)
> t.Start(100)
>
> frame.Show()
> app.MainLoop()
>
>
>
> --
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualiz

Re: [Matplotlib-users] Date format the x-axis of a barh() plot?

2011-04-27 Thread jfortiv

This worked.  Thank you very much!  For some reason I had commented out
ax.fmt_xdata = ...

This is exactly what I needed.  

James


Goyo wrote:
> 
> 2011/4/23 jfortiv :
>>
>> Hi,
>>
>> This actually did not work for me.  Can you show me the full code that
>> you
>> used to successfully produce the time-format x-axis labels?
> 
> See attached files.
> 
> Goyo
> 
>  
>  
> --
> Fulfilling the Lean Software Promise
> Lean software platforms are now widely adopted and the benefits have been 
> demonstrated beyond question. Learn why your peers are replacing JEE 
> containers with lightweight application servers - and what you can gain 
> from the move. http://p.sf.net/sfu/vmware-sfemails
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Date-format-the-x-axis-of-a-barh%28%29-plot--tp31420395p31493421.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How do I make the radius logarithmic with axisartist?

2011-04-27 Thread Jae-Joon Lee
The Axes class of the axisartist toolkit uses very different way to
handle ticks and tick labels. Thus most of the tick-related commands
of original matplotlib do not work!

Unfortunately, there is no easy way to support a logarithmic scale.

To utilize the full functionality, you need to create a transform
object and provide an appropriate tick locator. The first part is easy
but the second part is not. You can use origial mapltolib's tick
locator, but it has a limitation that minor ticks are not well
supported.

The easiest way is to convert your data to log scale and use a fixed
locator with a custom formatter. An example script is attached.

The better approach is to create your own locator and formatter.

Regards,

-JJ


On Fri, Apr 22, 2011 at 1:49 AM, Junghun Shin
 wrote:
> Hi, everyone.
>
> Let me explain what I wanted to do: First, I wanted to make a polar
> plot with angles from 0 to 90. I could do it by adopting the
> curvelinear grid demo ( http://goo.gl/kruXf ). And then I wanted to
> present the radius in log10 scale. But setting the plot command to
> semilogy or trying to set 'set_rscale('log')' all failed. Below I
> pasted the code that works for radius in linear scale.
>
> [Code]
> #!/usr/bin/env python
> import matplotlib.pyplot as plt
> import numpy as np
>
> #Modified from 
> http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/demo_floating_axis.py
>
> #def curvelinear_test2(fig, lp_r, lp_t):
> def curvelinear_test2(fig, lp_t, lp_r, rLower, rUpper):
>    rmin = np.min(lp_r)
>    rmax = np.max(lp_r)
>    print 'rm: ', rmin, 'rM: ', rmax,'rL: ', rLower, 'rU: ', rUpper
>    """
>    polar projection, but in a rectangular box.
>    """
>    global ax1
>    import  mpl_toolkits.axisartist.angle_helper as angle_helper
>    from matplotlib.projections import PolarAxes
>    from matplotlib.transforms import Affine2D
>
>    from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans
>
>    from mpl_toolkits.axisartist import GridHelperCurveLinear
>
>    from  mpl_toolkits.axisartist.grid_helper_curvelinear import
> GridHelperCurveLinear
>
>
>    # see demo_curvelinear_grid.py for details
>    tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
>
>    extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
>                                                     lon_cycle = 360,
>                                                     lat_cycle = None,
>                                                     lon_minmax = (0, 360),
>                                                     lat_minmax =
> (-np.inf, np.inf),
>                                                     #lat_minmax =
> (rmin, np.inf),
>                                                     )
>
>    grid_locator1 = angle_helper.LocatorDMS(12)
>
>    tick_formatter1 = angle_helper.FormatterDMS()
>
>    grid_helper = GridHelperCurveLinear(tr,
>                                        extreme_finder=extreme_finder,
>                                        grid_locator1=grid_locator1,
>                                        tick_formatter1=tick_formatter1
>                                        )
>
>
>    ax1 = SubplotHost(fig, 1, 1, 1, grid_helper=grid_helper)
>
>    fig.add_subplot(ax1)
>
>    # make ticklabels of all axis visible.
>    ax1.axis[:].major_ticklabels.set_visible(True)
>    #ax1.axis["top"].major_ticklabels.set_visible(True)
>    #ax1.axis["left"].major_ticklabels.set_visible(True)
>    #ax1.axis["bottom"].major_ticklabels.set_visible(True)
>
>    # show angle (0) at right and top
>    ax1.axis["right"].get_helper().nth_coord_ticks=0
>    ax1.axis["top"].get_helper().nth_coord_ticks=0
>
>    # show radius (1) at left and bottom
>    ax1.axis["left"].get_helper().nth_coord_ticks=1
>    ax1.axis["bottom"].get_helper().nth_coord_ticks=1
>
>    # set labels
>    ax1.axis["left"].label.set_text(r'ylabel')
>    ax1.axis["bottom"].label.set_text(r'xlabel')
>    ax1.axis["bottom"].major_ticklabels.set_rotation(-30)
>
>    ax1.set_aspect(1.)
>    ax1.set_xlim(rLower, rUpper)
>    ax1.set_ylim(rLower, rUpper)
>    #ax1.rscale('log')
>
>    # A parasite axes with given transform
>    ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
>    # note that ax2.transData == tr + ax1.transData
>    # Anthing you draw in ax2 will match the ticks and grids of ax1.
>    ax1.parasites.append(ax2)
>
>    ax2.plot(lp_t, lp_r, 'o-')
>    #ax2.semilogy(lp_t, lp_r, 'o-')
>    #ax2.set_rscale('log')
>    #ax1.set_xscale('log')
>    #ax1.set_yscale('log')
>
>    ax1.grid(True)
>
> if __name__ == "__main__":
>
>   fig = plt.figure(1, figsize=(5, 5))
>   fig.clf()
>
>   rmin = 1e-1
>   rmax = 1e2
>   lp_t = np.linspace(0., 90., 5)
>   lp_r = np.linspace(rmin, rmax/10, 5)*5
>
>   print "lp_t: ", lp_t
>   print "lp_r: ", lp_r
>   print "log10(lp_r): ", np.log10(lp_r)
>
>   curvelinear_test2(fig, lp_t, lp_r, rmin, rmax)
>   #curvelinear_test2(fig, lp_t, np.log10(lp_r), np.log10(rmin), np.log(rmax))
>
>   plt.show()