Re: [Matplotlib-users] matplotlib is slow

2013-01-02 Thread Michael Droettboom
I think using the profiler is the best bet here.  We've used that in the 
past to track down things that take a long time to import quite 
successfully.  I'm not seeing any slowness here, so that is likely do to 
an environmental difference on your machine, implying you'll really need 
to run the profiler yourself.  I recommend runsnakerun to examine the 
profile output -- if you have trouble interpreting it, feel free to send 
me your raw profiler data to me off list.


Mike

On 12/31/2012 02:21 PM, C M wrote:

Resurrecting an old thread here

On Tue, Mar 29, 2011 at 3:23 PM, David Kremer da...@david-kremer.fr 
mailto:da...@david-kremer.fr wrote:


 I would recommend running the import in the Python profiler to
determine
 where most of the time is going.  When I investigated this a few
years
 back, it was mainly due to loading the GUI toolkits, which are
 understandably quite large.  You can avoid most of that by using
the Agg
 backend.  If you're using the Agg backend and still experiencing
 slowness, it may be that load-up issues have crept back into
matplotlib
 since then -- but we need profiling data to figure out where and
how.


Importing Matplotlib is very slow for me, too.  For a wxPython 
application with embedded Matplotlib, I am getting load times of  
20 seconds when cold importing matplotlib, with this (circa mid 
2004) computer setup:  Windows XP, sp3, Intel Pentium, 1.70 Ghz, 1 GB 
RAM.


This is, by the way, an import well after Python and wxPython have 
already been loaded into RAM, as it happens by a user action, so none 
of the time involved here is due to loading Python or wxPython (they 
both load more quickly--about 10 seconds to cold import them, my code, 
images, and some other libraries).


First of all:  does that amount of time seem appropriate for that fast 
of a system--or is that too long?  It definitely *feels* way too long 
from a user perspective (for comparison Word or PowerPoint loads on 
this computer in about 2.5 seconds).


Trying to improve it and following this old thread, I have switched to

matplotlib.use('Agg')

instead of

matplotlib.use('wxAgg')

as suggested to speed things up...but it is no faster.

I see, though, that I also have lines such as:

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg

Would the presence of these imports obviate the fact that I switched 
to using the Agg instead of the wxAgg?  If so, is there any way to use 
something faster here (I suspect not but thought I'd ask).


Also, what else should I consider doing to reduce the import time 
significantly?  (I have to learn how to use the profiler, so I haven't 
done that yet).


Thanks,
Che


 Mike

Thank you a lot for your answer.

I noticed than _matplotlib.pyplot_ is longer to be imported the
first time than
if it has already been imported previously (maybe things are
already loaded in
ram memory), and we don't need to fetch it from the hard drive
thanks to the
kernel.

As far I see, the function calls are the same for the two logs I
obtained,
except than the first took 6s instead of 1.4s.




The two logs have been obtained using :
code
python -m cProfile temp.py
/code

where temp.py consist of two lines :

code
#!/usr/bin/env python2

import matplotlib.pyplot
/code






--
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
mailto:Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412


___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 ___
Matplotlib-users 

[Matplotlib-users] open circles aren't showing up in the legend box

2013-01-02 Thread Joe Louderback
Using matplotlib.pyplot I create a scatter plot using two symbols, an open
circle, and a filled circle.  The legend for this plot shows both labels,
but there is no symbol for the open circles (see
missing_legend_circles.png).  Switching to matplotlib.pylab yields the same
result.  However, from an ipython --pylab session the open circles are
displayed in the legend.  This has me more baffled than usual.  Here's the
code to reproduce the enclosed figure:

import matplotlib.pyplot as plt

fig = plt.figure()
plot = fig.add_subplot(111)

plot.scatter([1, 2, 3], [4, 5, 6], c = [0.2, 0.4, 0.6], label = 'one',
 cmap = 'jet', marker = 'o', edgecolor = 'face')

plot.scatter([1, 2, 3], [7, 6, 5], c = [0.2, 0.4, 0.6], label = 'two',
  cmap = 'jet', marker = 'o', edgecolor = 'face',
  facecolor = 'none')
plot.legend()
plt.show()


This is with matplotlib 1.1 and 1.2 on Windows 7 with the TkAgg, WxAgg and
WX backends.

Thank you for any help.

-- Joe Louderback
attachment: missing_legend_circles.png--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users