You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
| 2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
| 2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
| 2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
| 2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
| 2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
| 2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
| 2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
| 2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
| 2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
| 2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
| 2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
| 2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
| 2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(22) |
2
(14) |
3
(3) |
4
(2) |
|
5
(2) |
6
(3) |
7
(2) |
8
(5) |
9
(19) |
10
(9) |
11
(8) |
|
12
(4) |
13
(14) |
14
(5) |
15
(4) |
16
(8) |
17
(4) |
18
(5) |
|
19
(4) |
20
(17) |
21
(14) |
22
(15) |
23
(7) |
24
(6) |
25
|
|
26
(1) |
27
(4) |
28
(5) |
29
(6) |
30
(8) |
31
(3) |
|
|
From: John H. <jdh...@ac...> - 2004-12-20 20:20:04
|
>>>>> "Dominique" == Dominique Orban <Dom...@po...> writes:
Dominique> I have also tried to resize the image but the same is
Dominique> happening. Should i reset the origin of the image
Dominique> manually somewhere?
This bug was mentioned and fixed in the figimage code I submitted in
the earlier post. Sorry if it wasn't clear. Here is the modified
function again; replace the pytlab.py function by the same name
# the modified figimage function
def figimage(*args, **kwargs):
# allow callers to override the hold state by passing hold=True|False
try: ret = gcf().figimage(*args, **kwargs)
except ValueError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
raise RuntimeError(msg)
except RuntimeError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
raise RuntimeError(msg)
draw_if_interactive()
gci._current = ret
return ret
figimage.__doc__ = Figure.figimage.__doc__ + """
Addition kwargs: hold = [True|False] overrides default hold state"""
-------------------------------------------------------
|
|
From: Todd M. <jm...@st...> - 2004-12-20 20:02:16
|
Hi John,
I looked over the diffs and they look fine; your analysis sounds
plausible to me. I'll try to reproduce the problem using the test
script and see if your fix removes it. If so, I'll go ahead and commit
the changes.
Todd
On Mon, 2004-12-20 at 13:12 -0600, John Hunter wrote:
> >>>>> "Axel" == Axel Kowald <A.K...@gm...> writes:
> Axel> This is not really appropriate for me, since I read some
> Axel> user input and decide then (after the script is running) if
> Axel> I produce screen output or only a PS file :-(
>
> Axel> If you or anyone else finds a solution, please let me know.
>
> So this has nothing to do with the ps save. The core problem is
> exposed by
>
> from pylab import *
> plot([1,2,3])
>
> with interactive false and no call to show. I traced the source of
> the error message to binding the destroy event to the window.
> Apparently the destroy is being called but the window is never shown.
> By moving the destroy binding into the figure manager show method, all
> appears to be fixed. Todd, you may want to look over this but I think
> it's sound
>
> Axel, try replacing the FigureManagerTkAgg code in
> site-packages/matplotlib/backends/backend_tkagg.py with the following
>
> class FigureManagerTkAgg(FigureManagerBase):
> """
> Public attributes
>
> canvas : The FigureCanvas instance
> num : The Figure number
> toolbar : The tk.Toolbar
> window : The tk.Window
> """
> def __init__(self, canvas, num, window):
> FigureManagerBase.__init__(self, canvas, num)
> self.window = window
> self.window.withdraw()
> self.window.wm_title("Figure %d" % num)
> self.canvas = canvas
> self._num = num
> t1,t2,w,h = canvas.figure.bbox.get_bounds()
> w, h = int(w), int(h)
> self.window.minsize(int(w*3/4),int(h*3/4))
> if matplotlib.rcParams['toolbar']=='classic':
> self.toolbar = NavigationToolbar( canvas, self )
> elif matplotlib.rcParams['toolbar']=='toolbar2':
> self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
> else:
> self.toolbar = None
> if self.toolbar is not None:
> self.toolbar.update()
> self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
> self._shown = False
>
> def resize(self, event):
> width, height = event.width, event.height
> self.toolbar.configure(width=width) # , height=height)
>
> def show(self):
> def destroy(*args):
> self.window = None
> Gcf.destroy(self._num)
> if not self._shown: self.window.bind("<Destroy>", destroy)
>
> _focus = windowing.FocusManager()
> self.window.deiconify()
> self.canvas.draw()
> self._shown = True
>
> def add_subplot(self, *args, **kwargs):
> a = FigureManagerBase.add_subplot(self, *args, **kwargs)
> if self.toolbar is not None:
> self.toolbar.update()
> return a
>
> def add_axes(self, rect, **kwargs):
> a = FigureManagerBase.add_axes(self, rect, **kwargs)
> if self.toolbar is not None:
> self.toolbar.update()
> return a
>
> def set_current_axes(self, a):
> if a not in self.axes.values():
> error_msg_tkpaint('Axes is not in current figure')
> FigureManagerBase.set_current_axes(self, a)
>
> def destroy(self, *args):
> if Gcf.get_num_fig_managers()==0 and not matplotlib.is_interactive():
> if self.window is not None:
> self.window.quit()
> if self.window is not None:
> self.window.destroy()
> self.window = None
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: John H. <jdh...@ac...> - 2004-12-20 19:15:16
|
>>>>> "Axel" == Axel Kowald <A.K...@gm...> writes:
Axel> This is not really appropriate for me, since I read some
Axel> user input and decide then (after the script is running) if
Axel> I produce screen output or only a PS file :-(
Axel> If you or anyone else finds a solution, please let me know.
So this has nothing to do with the ps save. The core problem is
exposed by
from pylab import *
plot([1,2,3])
with interactive false and no call to show. I traced the source of
the error message to binding the destroy event to the window.
Apparently the destroy is being called but the window is never shown.
By moving the destroy binding into the figure manager show method, all
appears to be fixed. Todd, you may want to look over this but I think
it's sound
Axel, try replacing the FigureManagerTkAgg code in
site-packages/matplotlib/backends/backend_tkagg.py with the following
class FigureManagerTkAgg(FigureManagerBase):
"""
Public attributes
canvas : The FigureCanvas instance
num : The Figure number
toolbar : The tk.Toolbar
window : The tk.Window
"""
def __init__(self, canvas, num, window):
FigureManagerBase.__init__(self, canvas, num)
self.window = window
self.window.withdraw()
self.window.wm_title("Figure %d" % num)
self.canvas = canvas
self._num = num
t1,t2,w,h = canvas.figure.bbox.get_bounds()
w, h = int(w), int(h)
self.window.minsize(int(w*3/4),int(h*3/4))
if matplotlib.rcParams['toolbar']=='classic':
self.toolbar = NavigationToolbar( canvas, self )
elif matplotlib.rcParams['toolbar']=='toolbar2':
self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
else:
self.toolbar = None
if self.toolbar is not None:
self.toolbar.update()
self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
self._shown = False
def resize(self, event):
width, height = event.width, event.height
self.toolbar.configure(width=width) # , height=height)
def show(self):
def destroy(*args):
self.window = None
Gcf.destroy(self._num)
if not self._shown: self.window.bind("<Destroy>", destroy)
_focus = windowing.FocusManager()
self.window.deiconify()
self.canvas.draw()
self._shown = True
def add_subplot(self, *args, **kwargs):
a = FigureManagerBase.add_subplot(self, *args, **kwargs)
if self.toolbar is not None:
self.toolbar.update()
return a
def add_axes(self, rect, **kwargs):
a = FigureManagerBase.add_axes(self, rect, **kwargs)
if self.toolbar is not None:
self.toolbar.update()
return a
def set_current_axes(self, a):
if a not in self.axes.values():
error_msg_tkpaint('Axes is not in current figure')
FigureManagerBase.set_current_axes(self, a)
def destroy(self, *args):
if Gcf.get_num_fig_managers()==0 and not matplotlib.is_interactive():
if self.window is not None:
self.window.quit()
if self.window is not None:
self.window.destroy()
self.window = None
|
|
From: John H. <jdh...@ac...> - 2004-12-20 19:09:57
|
>>>>> "John" == John Hunter <jdh...@ac...> writes:
John> This change alone gives me more than a 2x speedup. So with
John> GTKAgg + a custom normalizer (in this case a do nothing
John> normalizer) you'll be running 4-5 times faster than you were
John> before, me thinks.
Of the remaining time, about half of it, on my system, is spent in the
colormapping. Almost all of this is in
LinearSegmentedColormap.__call__, and is split between these numerix
methods
0.12s zeros : create the RGBA colormapped output array
0.23s where : make sure the data are in the [0,1] interval
0.49s take + makeMappingArray - actually doing the mapping
You may not want or need some of the overhead and extra checking that
matplotlib does in the colormapping. Do you want colormapping at all
by the way?
If not, you can special case colormapping by simply converting to RGB
in the 0-255 interval. Note, as I said it is a bit inelegant that
everything has to go through RGB even if you don't need it. I have
some ideas here, but that will have to wait a bit.
from pylab import *
def mynorm(X):
return X
class mycmap:
name = "my gray"
def __call__(self, X, alpha=None):
# what is the fastest way to make an MxNx3 array simply
# duplicating MxN on the last dimension?
m,n = X.shape
Z = zeros((m,n,3), typecode=X.typecode())
Z[...,0] = X
Z[...,1] = X
Z[...,2] = X
return Z
#norm = None # default
norm = mynorm
#cmap = None # default
cmap = mycmap()
ion()
rc('figure', figsize=(13,12))
X = rand(1600,1600)
figimage(X, cmap=cmap, norm=norm)
With the following numbers
# default cmap
peds-pc311:~/python/projects/matplotlib> time python ~/test.py --numarray -dGTKAgg
1.630u 0.430s 0:02.12 97.1% 0+0k 0+0io 4746pf+0w
# custom cmap
peds-pc311:~/python/projects/matplotlib> time python ~/test.py --numarray -dGTKAgg
1.080u 0.290s 0:01.42 96.4% 0+0k 0+0io 4745pf+0w
Of this 1.42 seconds, the big chunks are
0.660 The time it takes to do from pylab import *; half of this is
initializing the colormaps and dicts in cm. We should do some
work to get this number down. But it is a fixed cost that
doesn't scale with array size
0.320 RandomArray2.py:97(random) # creating the dummy data. We can
ignore this
0.540 backend_gtkagg.py:33(draw) # this creates the entire figure,
of this, 0.420s is in the function FigureImage.make_image,
most of which is in the extension code _image.fromarray
So ignoring for now the fixed cost of loading modules and creating
your arrays (Eg by running in pylab using the "run" function you only
pay the module loading costs once), the next place where a big win is
going to come from is in optimizing fromarray.
Note, the matplotlib figure canvas is a drawable widget. If you want
bare metal speed and don't want any of the features matplotlib offers
(interpolation, normalization, colormapping, etc), you can always dump
your image directly to the gtk canvas, especially if you compile gtk
with image support. This may be useful enough for us to consider a
backend figimage pipeline which would bypass a number of extra
copies. Currently we have for gtkagg
numarray -> agg image buffer -> figure canvas agg buffer -> gtk canvas
With some care, we might be able to simplify this, ideally doing for
the canvas
numarray -> gtk canvas # for screen
numarray -> agg buffer # for dumping to PNG
There are some subtleties to think through as to how this would work.
It would probably need to be a canvas method and not a renderer
method, for one thing, which would take a bit of redesign.
And then Midas would have to watch its back!
JDH
|
|
From: Dominique O. <Dom...@po...> - 2004-12-20 18:14:43
|
Hello,
I just downloaded Matplotlib 0.65 in Windows XP, Python 2.3. I just
wanted to give 2 comments. First, when i try to use spy2() to plot a
sparsity pattern, i get an error saying that the global name 'where'
cannot be found. I can't remember if this has been mentioned in the past
week. I simply solved this by adding 'where' on line 8 of axes.py:
from numerix import MLab, absolute, arange, array, asarray, ones,
transpose, \
log, log10, Float, ravel, zeros, Int32, Float64, ceil, min, indices, \
shape, which, where
Sorry if this was a duplicate.
The second comment is about figimage(). Out of curiosity while reading
the discussion entitles "Re: [Matplotlib-users] Is really matplotlib
this slooow for displaying images ? (sorry again)" with Eric Emsellem, i
have tried the sample script
from matplotlib.pylab import *
X = rand( 100, 100 )
figimage( X )
show()
The window that pops up as an axes box but not plot inside. Instead, a
small image (representing X i assume) is located in the top left corner
of the window. This image 'overlaps' with the axes and its lower right
chunk is masked by the axes. If i rerun the same script using instead
X = rand( 1600, 1600 )
as in the discussion, the all the area _outside_ of the axes is filled
with the image, and there is nothing inside the axes box. Presumably,
the whole image area is filled and the axes box is added next, masking
part of the image.
I have also tried to resize the image but the same is happening. Should
i reset the origin of the image manually somewhere?
Thanks for a great package,
Dominique
|
|
From: Eric E. <ems...@ob...> - 2004-12-20 17:21:24
|
Test done and this is correct, here are the sets of timing : first line is without ''mynorm'', second is with ''mynorm''. time python test.py --Numeric -dTkAgg 10.432u 1.663s 0:12.37 97.7% 0+0k 0+0io 0pf+0w 7.258u 1.302s 0:08.64 98.9% 0+0k 0+0io 0pf+0w time python test.py --Numeric -dGTKAgg 5.209u 0.845s 0:06.10 99.0% 0+0k 0+0io 0pf+0w 4.226u 0.700s 0:04.98 98.7% 0+0k 0+0io 0pf+0w time python test.py --numarray -dTkAgg 16.391u 1.036s 0:17.96 96.9% 0+0k 0+0io 0pf+0w 5.690u 0.829s 0:06.85 95.0% 0+0k 0+0io 0pf+0w time python test.py --numarray -dGTKAgg 8.225u 0.546s 0:08.96 97.7% 0+0k 0+0io 0pf+0w 3.363u 0.445s 0:03.86 98.4% 0+0k 0+0io 0pf+0w Another factor of 10 and you are faster than Midas.. :-) Eric John Hunter wrote: >>>>>>"John" == John Hunter <jdh...@ac...> writes: >>>>>> >>>>>> > > John> I'll spend some time with the profiler looking for some low > John> hanging fruit. > >God bless the profiler. It turns out over half of the time to display >this image is spent in the normalizer, which takes image data in an >arbitrary scale and maps into the unit interval > > http://matplotlib.sourceforge.net/matplotlib.colors.html#normalize > >The normalizer handles a lot of special cases that you may not need. >In fact, your data may already be normalized. So you can write a >custom normalizer > >from pylab import * > >def mynorm(X): # do nothing, it's already normalized > return X > >ion() > >rc('figure', figsize=(13,12)) >X = rand(1600,1600) >figimage(X, cmap=cm.hot, norm=mynorm) > > >This change alone gives me more than a 2x speedup. So with GTKAgg + a >custom normalizer (in this case a do nothing normalizer) you'll be >running 4-5 times faster than you were before, me thinks. > >peds-pc311:~/python/projects/matplotlib> time python ~/test.py --numarray >1.650u 0.450s 0:02.13 98.5% 0+0k 0+0io 4746pf+0w > >I'll keep digging through the profiler... > >JDH > > > -- =============================================================== Observatoire de Lyon ems...@ob... 9 av. Charles-Andre tel: +33 4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem =============================================================== |
|
From: Eric E. <ems...@ob...> - 2004-12-20 17:17:42
|
Hi, thanks for the feedback. To answer your questions: - I have both Numeric and numarry but I am using numarray in principle. - Running in verbose mode, here is the output: matplotlib data path /usr/share/matplotlib loaded rc file /home/emsellem/.matplotlibrc matplotlib version 0.65 verbose.level helpful interactive is False platform is linux2 numerix numarray 1.0 font search path ['/usr/share/matplotlib'] loaded ttfcache file /home/emsellem/.ttffont.cache Could not load matplotlib icon: 'module' object has no attribute 'window_set_default_icon_from_file' backend GTKAgg version 2.0.0 - Then a VERY important note: yes indeed I am an astronomer and I am used to have a fixed window (I first define its size or use some default) and THEN ONLY load the image itself. This is how I use ppgplot in python or Iraf, or Midas. I indeed to not then use any interpolation scheme there. - ALSO: there seems to be a bug in the figimage routine as it shows the image OUTSIDE an axis filled with white (this may be because I am not doing the right thing though...) - And finally here are the timing you asked for: (there seem to be reasonable considering the difference in CPU/RAM) Hope this helps Eric ================================================== Before correcting figima ========================= time python test.py --Numeric -dTkAgg 14.146u 2.363s 0:17.79 92.7% 0+0k 0+0io 10pf+0w time python test.py --Numeric -dGTKAgg 9.795u 1.697s 0:13.63 84.2% 0+0k 0+0io 12pf+0w time python test.py --numarray -dTkAgg 22.640u 1.443s 0:25.31 95.1% 0+0k 0+0io 13pf+0w time python test.py --numarray -dGTKAgg 15.125u 0.925s 0:16.26 98.6% 0+0k 0+0io 0pf+0w After correcting figima ========================= time python test.py --Numeric -dTkAgg 10.432u 1.663s 0:12.37 97.7% 0+0k 0+0io 0pf+0w time python test.py --Numeric -dGTKAgg 5.209u 0.845s 0:06.10 99.0% 0+0k 0+0io 0pf+0w time python test.py --numarray -dTkAgg 16.391u 1.036s 0:17.96 96.9% 0+0k 0+0io 0pf+0w time python test.py --numarray -dGTKAgg 8.225u 0.546s 0:08.96 97.7% 0+0k 0+0io 0pf+0w -- =============================================================== Observatoire de Lyon ems...@ob... 9 av. Charles-Andre tel: +33 4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem =============================================================== |
|
From: John H. <jdh...@ac...> - 2004-12-20 17:07:29
|
>>>>> "John" == John Hunter <jdh...@ac...> writes:
John> I'll spend some time with the profiler looking for some low
John> hanging fruit.
God bless the profiler. It turns out over half of the time to display
this image is spent in the normalizer, which takes image data in an
arbitrary scale and maps into the unit interval
http://matplotlib.sourceforge.net/matplotlib.colors.html#normalize
The normalizer handles a lot of special cases that you may not need.
In fact, your data may already be normalized. So you can write a
custom normalizer
from pylab import *
def mynorm(X): # do nothing, it's already normalized
return X
ion()
rc('figure', figsize=(13,12))
X = rand(1600,1600)
figimage(X, cmap=cm.hot, norm=mynorm)
This change alone gives me more than a 2x speedup. So with GTKAgg + a
custom normalizer (in this case a do nothing normalizer) you'll be
running 4-5 times faster than you were before, me thinks.
peds-pc311:~/python/projects/matplotlib> time python ~/test.py --numarray
1.650u 0.450s 0:02.13 98.5% 0+0k 0+0io 4746pf+0w
I'll keep digging through the profiler...
JDH
|
|
From: John H. <jdh...@ac...> - 2004-12-20 16:50:23
|
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
Eric> Hi, I am using:
Eric> IPython 0.6.6 with Python 2.3.3 and matplotlib-0.65
OK, too bad, one of the most common causes of slow behavior on earlier
versions of matplotlib was a numeric/numarray incompatibility setting
as discussed here - http://matplotlib.sourceforge.net/faq.html#SLOW.
But with 0.65, this shouldn't be a problem. But just to be certain
- do you have Numeric and numarray on your system?
- what is the output of any test script when run with
--verbose-helpful.
It is important that you are not mixing numeric and numarray in your
code, because then matplotlib falls back on the python sequence
protocol. So I just want to insure that you are using numarray
consistently and that matplotlib knows it.
Eric> (checked that this is indeed the case)
Eric> Eric P.S.: by the way, just to let you know (and I will pass
Eric> the message on the forum) I am sincerely very impressed by
Eric> matplotlib in general (in fact 5 people just switched to it
Eric> in the last 2 weeks and our group only amounts to 10 people
Eric> so 1/2 still to convince!). So this kind of ''negative''
Eric> feedback/question should not undermine the rest of the soft
Eric> for sure!!!
I passed it on already. I suspect there are a number of others who
are interested in and can contribute to this discussion so I'll keep
this on list for a bit. Thanks for the moral support :-)
A bit of background: as Arnd pointed out, imshow is probably doing a
lot more under the hood than you need, so I suggest we stick with
figimage for a while. I assume you're an astronomer, since you
mentioned IRAF, no? Perry Greenfield, also an astronomer, suggested
figimage because he mainly wanted a pixel dump of his data, with no
interpolation that imshow provides.
Do you need color mapping, or mainly grayscale? The reason I ask is
that for simplicity of coding I convert everything to an RGBA under
the hood, which is obviously inefficient in memory and CPU time. At
some point (maybe now), we'll have to special case grayscale for
people who can't pay those extra costs. I don't know if this is where
your bottleneck is.
So assuming figimage for now, I wrote a test script to get some
numbers for comparison. Then I noticed I had introduced a bug in 0.65
in figimage when I wrongly added "hold" control to figimage, where it
doesn't below. So replace figimage in pylab.py with the function I'm
including below before running any tests.
Since most people can't fit a 1600x1600 image on screen (I can't),
we'll need a big figure window at least to get most of it.. That's
what the figsize command is for. FYI, my suspicion is we should be
able to get acceptable performance for 1600x1600 or 2000x2000 and
images of this magnitude, with some basic refactoring and
optimization. I doubt we'll get 20k x 20k in the forseeable future,
in large part because the underlying image library from antigrain only
does 4096x4096.
With this script, I'm running in interactive mode ("ion") so the
figure will be created when the figimage call is made, and then will
immediately terminate rather than go into the tk mainloop since show
is called.
from pylab import *
ion()
rc('figure', figsize=(13,12))
X = rand(1600,1600)
figimage(X, cmap=cm.hot)
#show()
Here are my numbers. Note I can get almost a 2x performance boost
switching to GTKAgg - there are known performance issues blitting a
large image to tkinter. Is GTKAgg as possibility for you?
peds-pc311:~> time python test.py --Numeric -dTkAgg
5.750u 1.730s 0:08.20 91.2% 0+0k 0+0io 3286pf+0w
peds-pc311:~> time python test.py --Numeric -dGTKAgg
3.280u 0.840s 0:04.16 99.0% 0+0k 0+0io 4579pf+0w
peds-pc311:~> time python test.py --numarray -dTkAgg
8.830u 1.100s 0:09.96 99.6% 0+0k 0+0io 3455pf+0w
peds-pc311:~> time python test.py --numarray -dGTKAgg
4.730u 0.560s 0:05.36 98.6% 0+0k 0+0io 4747pf+0w
with a 3GHz P4 with 1GB of RAM. How do the numbers for your system
compare?
I'll spend some time with the profiler looking for some low hanging
fruit.
JDH
# the modified figimage function
def figimage(*args, **kwargs):
# allow callers to override the hold state by passing hold=True|False
try: ret = gcf().figimage(*args, **kwargs)
except ValueError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
hold(b)
raise RuntimeError(msg)
except RuntimeError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
hold(b)
raise RuntimeError(msg)
draw_if_interactive()
gci._current = ret
return ret
figimage.__doc__ = Figure.figimage.__doc__ + """
Addition kwargs: hold = [True|False] overrides default hold state"""
|
|
From: Chris F. <the...@gm...> - 2004-12-20 16:21:14
|
I am encountering difficulties with the ylabel for plots that I create. The label is placed over top of the tick mark labels on the y axis. I have attempted to move the label using the set_position and set_x commands. In this way, I have been able to move the label in the y direction but not in the x direction. Essentially, I have been unable to move the label to the left of the tick marks. I am using the Enthought Edition of Python 2.3.3. I have matplotlib in interactive mode using backend WX. I chose this configuration because it seems best suited for use with PythonWin, which provides me with autocompletion capabilities. Any suggestions for resolving my problem? |
|
From: Eric E. <ems...@ob...> - 2004-12-20 16:07:22
|
Hi, I am using: IPython 0.6.6 with Python 2.3.3 and matplotlib-0.65 (checked that this is indeed the case) Eric P.S.: by the way, just to let you know (and I will pass the message on the forum) I am sincerely very impressed by matplotlib in general (in fact 5 people just switched to it in the last 2 weeks and our group only amounts to 10 people so 1/2 still to convince!). So this kind of ''negative'' feedback/question should not undermine the rest of the soft for sure!!! -- =============================================================== Observatoire de Lyon ems...@ob... 9 av. Charles-Andre tel: +33 4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem =============================================================== |
|
From: John H. <jdh...@ac...> - 2004-12-20 16:01:15
|
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
Eric> If there is no way out, I may have to just abandon (sigh)
Eric> matplotlib for displaying images. But if there is one,
Eric> please let me know!!
What version of matplotlib are you using?
>>> import matplotlib
>>> matplotlib.__version__
JDH
|
|
From: Alan I. <ai...@am...> - 2004-12-20 14:51:37
|
On Mon, 20 Dec 2004, Xavier Gnata wrote: > I have tried to install matplotlib on windows : > I have installed the enthought edition of python but I'm > now unable to install matplotlib because I haven't visual > C++ 6.0. Why not use the Windows installer? Works great. hth, Alan Isaac |
|
From: Axel K. <A.K...@gm...> - 2004-12-20 10:31:37
|
Hi John,
> >> Fatal Python error: PyEval_RestoreThread: NULL tstate This
> >> application has requested the Runtime to terminate it in an
> Axel> unusual way.
> >> Please contact the application's support team for more
> >> information.
>
>This error has cropped up before in other contexts, always on win32,
>and I think a common cause is when you import the tk backend but do
>not start the tk mainloop (which is what show does), which is what I
>suspect you are doing since this is the default backend on win32.
>
Yes, that's exactly what's happening. I'm using winXP with matplotlib
0.65 and Activestate Python 2.3.2
>Does the
>minimal script, which does nothing but "import pylab" replicate the
>problem?
>
>
>
This replictes the problem:
#!/usr/bin/env python
from pylab import *
rcParams['interactive'] = False
plot([1,2,3])
savefig('bla.ps')
>Do you know that you can run the script with -dPS from the shell to
>switch the backend?
>
This is not really appropriate for me, since I read some user input and
decide then (after the script is running) if I produce screen output or
only a PS file :-(
If you or anyone else finds a solution, please let me know.
Many thanks,
Axel
|
|
From: Arnd B. <arn...@we...> - 2004-12-20 09:21:02
|
Hi Eric,
I am certain that John will be very delighted
to have another of the "matplotlib is slow" e-mails ;-).
Let me therefore add my 2 cents on this before he
wakes up (hope I have the timezones right)
and gives a qualified comment on this ...
On Mon, 20 Dec 2004, Eric Emsellem wrote:
[... timings etc snipped ... ]
> Some info:
>
> running on a 1.6 Ghz/512 RAM centrino, linux, backend TkAgg, numarray,
> float array of 1600x1600 pixels.
> Using either imshow or figimage in ''ipython -pylab'' (tried different
> interpolation schemes
> the one I want being ''nearest'' in general)
Did you also try a Numeric array?
Another point: the imshow routine
has quite a bit of functionality
(color maps, interpolation, even alpha!!!)
which might cost some time (for example, I don't
know whether all this is done in python).
You can also pass a PIL (Python Image Library) image
to imshow.
So I would suggest:
a) try a Numeric array
b) try to convert you matrix to a PIL image
and determine the time it takes to display that.
(I would hope that this is much faster)
> To be frank, this is a killer for me, since I need to work on such images
> (signal processing, analysing) and display them each time changing the
> levels, centring etc etc. There is no way I will wait for 1 mn for 3
> successive displays...
>
> So the question now:
> - am I doing something wrong (backend, way to load the array, ...) or is it
> intrinsic to matplotlib ?
To really answer this question it would be useful
if you post your code (presumably simplified
by creating some mock data without reading from an external file).
By this one could also try this on other platforms ...
[...]
Best,
Arnd
|
|
From: Xavier G. <gn...@ob...> - 2004-12-20 09:20:27
|
Hi, I have tried to install matplotlib on windows : I have installed the enthought edition of python but I'm now unable to install matplotlib because I haven't visual C++ 6.0. Is it realy important to have everything python-related compiled with the same compiler? Did someone succeed in installing matplotlib on windows without with the devcpp? (devcpp is based on the *free* compiler gcc). Xavier Gnata. |
|
From: Eric E. <ems...@ob...> - 2004-12-20 09:01:24
|
Hi, after some successful attempt at migrating routines from several plotting and/or analysing softwares (pgplot, Midas, Iraf, etc) to Matplotlib I now hit a big wall: the speed at which it can display a reasonably large image: - I have a ''local'' library to read fits files [2D images] in python (after SWIG wrapping). It converts these files into float - nmerix - arrays. I was then testing the ability of matplotlib to display these 2D arrays. Until now all was fine since I tested matplotlib on very small images (50x50 pixels). Yesterday I tried with a 1600x1600 pixels image. NOTE: this is a very reasonable size (and typical) in my work and I expect much much bigger ones in a near future (up to 20 000 x 20 000). ==> Matplotlib takes ~20 seconds to display it !!! (after 12 seconds the window opens, and then it takes another 8 seconds to be displayed) (as compared to less than .2 sec for Midas, Iraf and others so a factor of 100 at least!!! and less than a second using the ppgplot routines). Some info: running on a 1.6 Ghz/512 RAM centrino, linux, backend TkAgg, numarray, float array of 1600x1600 pixels. Using either imshow or figimage in ''ipython -pylab'' (tried different interpolation schemes the one I want being ''nearest'' in general) To be frank, this is a killer for me, since I need to work on such images (signal processing, analysing) and display them each time changing the levels, centring etc etc. There is no way I will wait for 1 mn for 3 successive displays... So the question now: - am I doing something wrong (backend, way to load the array, ...) or is it intrinsic to matplotlib ? - is there a way out? (basically the same question..) If there is no way out, I may have to just abandon (sigh) matplotlib for displaying images. But if there is one, please let me know!! Thanks Eric -- =============================================================== Observatoire de Lyon ems...@ob... 9 av. Charles-Andre tel: +33 4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem =============================================================== |