SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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
(35)
2
(15)
3
(16)
4
(3)
5
(1)
6
(1)
7
(11)
8
(10)
9
(13)
10
(24)
11
(21)
12
(10)
13
(2)
14
(24)
15
(20)
16
(36)
17
(13)
18
(6)
19
(4)
20
(2)
21
(11)
22
(13)
23
(7)
24
(10)
25
(7)
26
(12)
27
(2)
28
(6)
29
(20)
30
(9)
31
(39)


Showing 13 results of 13

From: Eric F. <ef...@ha...> - 2008年07月09日 21:07:53
Marjolaine Rouault wrote:
> Hi,
> 
> I don't understand how one creates his own colormap. i am using
> matplotlib and I have checked the example in
> http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps but I can't
> really understand how it works. Are there any other examples out
> there? I want to create a colormap a bit like the one at this url:
> 
> http://www.pyngl.ucar.edu/Graphics/Images/ViBlGrWhYeOrRe.gif
> 
> best regards, Marjolaine.
> 
> 
> 
Marjolaine,
Depending on your starting point--what you know about your desired 
colormap--you can use either a LinearSegmentedColormap or a 
ListedColormap. If you already have a colormap in the form of a list of 
evenly-spaced colors, then the simplest way to get it into mpl is by 
using that list to initialize a ListedColormap. If, instead, you have a 
general idea of how you want R, G, and B to vary over the range of the 
map, then you probably need the LinearSegmentedColormap.
Every description of the LinearSegmentedColormap class that I have seen 
is confusing, even though the way it works is fairly simple. Let's see 
if I can make it a little less confusing.
Example: suppose you want red to increase from 0 to 1 over the bottom 
half, green to do the same over the middle half, and blue over the top 
half. Then you would use:
cdict = { 'red': ((0, 0, 0),
 (0.5, 1, 1),
 (1, 1, 1)),
 'green': ((0, 0, 0),
 (0.25, 0, 0),
 (0.75, 1, 1),
 (1, 1, 1)),
 'blue': ((0, 0, 0),
 (0.5, 0, 0),
 (1, 1, 1))}
If, as in this example, there are no discontinuities in the r, g, and b 
components, then it is quite simple: the second and third element of 
each tuple, above, is the same--call it "y". The first element ("x") 
defines interpolation intervals over the full range of 0 to 1, and it 
must span that whole range. In other words, the values of x divide the 
0-to-1 range into a set of segments, and y gives the end-point color 
values for each segment.
Now consider the green. cdict['green'] is saying that for
0 <= x <= 0.25, y is zero; no green.
0.25 < x <= 0.75, y varies linearly from 0 to 1.
x > 0.75, y remains at 1, full green.
If there are discontinuities, then it is a little more complicated. 
Label the 3 elements in each row in the cdict entry for a given color as 
(x, y0, y1). Then for values of x between x[i] and x[i+1] the color 
value is interpolated between y1[i] and y0[i+1].
Going back to the cookbook example, look at cdict['red']; because y0 != 
y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1, 
but then it jumps down, so that for x from 0.5 to 1, red increases from 
0.7 to 1. Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps 
back to 0, and ramps back to 1 as x goes from 0.5 to 1.
row i: x y0 y1
 /
 /
row i+1: x y0 y1
Above is an attempt to show that for x in the range x[i] to x[i+1], the 
interpolation is between y1[i] and y0[i+1]. So, y0[0] and y1[-1] are 
never used.
I hope I got all that right--I would welcome close checking. I want to 
get an adequate and correct explanation into the standard mpl documentation.
Eric
From: Michael M. <mmu...@hu...> - 2008年07月09日 18:56:07
Greetings
Having followed the build instructions for matplotlib on the website, 
I continue to get the error(s):
sh-3.2# python setup.py build
= 
= 
= 
= 
========================================================================
BUILDING MATPLOTLIB
 matplotlib: 0.98.1
 python: 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 
4.0.1
 (Apple Computer, Inc. build 5341)]
 platform: darwin
REQUIRED DEPENDENCIES
 numpy: 1.1.0
 freetype2: found, but unknown version (no pkg-config)
 * WARNING: Could not find 'freetype2' headers 
in any
 * of '.', './freetype2'.
OPTIONAL BACKEND DEPENDENCIES
 libpng: found, but unknown version (no pkg-config)
 * Could not find 'libpng' headers in any of '.'
 Tkinter: Tkinter: 50704, Tk: 8.4, Tcl: 8.4
 wxPython: no
 * wxPython not found
 Gtk+: no
 * Building for Gtk+ requires pygtk; you must 
be able
 * to "import gtk" in your build/install 
environment
 Qt: no
 Qt4: no
 Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
 datetime: present, version unknown
 dateutil: matplotlib will provide
 pytz: matplotlib will provide
OPTIONAL USETEX DEPENDENCIES
 dvipng: 1.9
 ghostscript: 8.61
 latex: 3.141592
EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES
 configobj: matplotlib will provide
 enthought.traits: no
[Edit setup.cfg to suppress the above messages]
= 
= 
= 
= 
========================================================================
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.macosx-10.3- 
fat-2.5/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/ 
lib.macosx-10.3-fat-2.5/matplotlib/mpl-data
running build_ext
building 'matplotlib.ft2font' extension
g++ -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g - 
bundle -undefined dynamic_lookup -arch ppc -arch i386 -L/Users/Mike/ 
erange_staging/libpng-1.2.29 -L/Users/Mike/erange_staging/ 
freetype-2.3.7 -arch ppc -arch i386 -I/Users/Mike/erange_staging/ 
libpng-1.2.29 -I/Users/Mike/erange_staging/freetype-2.3.7/include 
build/temp.macosx-10.3-fat-2.5/src/ft2font.o build/temp.macosx-10.3- 
fat-2.5/src/mplutils.o build/temp.macosx-10.3-fat-2.5/CXX/ 
cxx_extensions.o build/temp.macosx-10.3-fat-2.5/CXX/cxxsupport.o build/ 
temp.macosx-10.3-fat-2.5/CXX/IndirectPythonInterface.o build/ 
temp.macosx-10.3-fat-2.5/CXX/cxxextensions.o -lfreetype -lz -lstdc++ - 
lm -o build/lib.macosx-10.3-fat-2.5/matplotlib/ft2font.so
ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libPng.dylib, 
file is not of required architecture for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccpblNox.out (No such file or 
directory)
error: command 'g++' failed with exit status 1
I am running on a Mac OS X 10.5 system and even though I set the 
CFLAGS and LDFLAGS I can't seem to point the build to the correct tree.
Note: I am a newbie relative to python on a Mac.
Can anyone point out an error I've made or offer troubleshooting 
suggestions?
Thanks
Mike
From: Michael D. <md...@st...> - 2008年07月09日 17:41:15
The matplotlib developers don't maintain that repository (which appears 
to be empty at present). Send a note of to its owner.
matplotlib (of some version at least) exists in the standard Debian 
repositories. You can install it from there. Or install from source if 
you need something newer.
Cheers,
Mike
Ben Axelrod wrote:
>
> I get errors when I add:
>
> deb http://anakonda.altervista.org/debian packages/
>
> deb-src http://anakonda.altervista.org/debian sources/
>
> to my /etc/apt/sources.list. Is this still the preferred method for 
> installing on Debian?
>
> 
>
> Thanks,
>
> -Ben
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Ben A. <bax...@co...> - 2008年07月09日 17:37:30
I get errors when I add:
 deb http://anakonda.altervista.org/debian packages/
 deb-src http://anakonda.altervista.org/debian sources/
to my /etc/apt/sources.list. Is this still the preferred method for installing on Debian?
Thanks,
-Ben
From: Darren D. <dsd...@gm...> - 2008年07月09日 16:59:07
On Wednesday 09 July 2008 12:40:29 pm anirudh vij wrote:
> > We have been warning that 3D plotting was unsupported and needed someone
> > to volunteer to maintain it for quite a while now. Nobody answered the
> > call, and 3d capabilities did not survive the transition to the new
> > transforms in mpl-0.98, so it was removed, However...
>
> hmm. Mayavi2 has a mlab module thats under active development. It aims
> to do the same stuff that matlab 3D plots do. However, svn currently
> crashes for me.
>
> > [...]
> >
> >> matplotlib version is 0.91.2, straight from ubuntu repos.
> >
> > 3D support should still be present in 0.91.x. I just did a clean install
> > of 0.91.4 from svn, and this works:
> >
> > import pylab as p
> > import matplotlib.axes3d as p3
> > fig=p.figure()
> > ax = p3.Axes3D(fig)
> > p.show()
> >
> > I haven't used matplotlib's 3d capabilities, so I dont know how you
> > expected to work with "from pylab import *" instead of the above. Perhaps
> > you could give a short explicit example of what used to work and now does
> > not.
>
> -----
> from pylab import *
> import matplotlib.axes3d as p3
> fig=figure()
> ax= p3.Axes3D(fig)
> ax.scatter3D(x,y,z)
> show()
> -----
> this causes an error. 
I can't help much if you don't tell me what the error is. I just ran the 
following and I did not observe any error:
from pylab import *
x=rand(100)
y=rand(100)
z=rand(100)
import matplotlib.axes3d as p3
fig=figure()
ax= p3.Axes3D(fig)
ax.scatter3D(x,y,z)
show()
> x,y,z are valid 1D arrays. They work using the 
> method you've posted in your mail.
>
> Perhaps a wrapper can be wriitten around mayavi's mlab module. 3D
> plotting is too important to leave out of something like matplotlib.
> Its perfect for all other things. It would be a pity if one has to
> switch to gnuplot or dislin just for 3D.
It sounds like a good idea to me. Submissions are very welcome.
Darren
From: anirudh v. <ani...@gm...> - 2008年07月09日 16:40:31
> We have been warning that 3D plotting was unsupported and needed someone to
> volunteer to maintain it for quite a while now. Nobody answered the call, and
> 3d capabilities did not survive the transition to the new transforms in
> mpl-0.98, so it was removed, However...
>
hmm. Mayavi2 has a mlab module thats under active development. It aims
to do the same stuff that matlab 3D plots do. However, svn currently
crashes for me.
> [...]
>> matplotlib version is 0.91.2, straight from ubuntu repos.
>
> 3D support should still be present in 0.91.x. I just did a clean install of
> 0.91.4 from svn, and this works:
>
> import pylab as p
> import matplotlib.axes3d as p3
> fig=p.figure()
> ax = p3.Axes3D(fig)
> p.show()
>
> I haven't used matplotlib's 3d capabilities, so I dont know how you expected
> to work with "from pylab import *" instead of the above. Perhaps you could
> give a short explicit example of what used to work and now does not.
-----
from pylab import *
import matplotlib.axes3d as p3
fig=figure()
ax= p3.Axes3D(fig)
ax.scatter3D(x,y,z)
show()
-----
this causes an error. x,y,z are valid 1D arrays. They work using the
method you've posted in your mail.
Perhaps a wrapper can be wriitten around mayavi's mlab module. 3D
plotting is too important to leave out of something like matplotlib.
Its perfect for all other things. It would be a pity if one has to
switch to gnuplot or dislin just for 3D.
From: Darren D. <dsd...@gm...> - 2008年07月09日 16:32:45
On Wednesday 09 July 2008 11:59:50 am anirudh vij wrote:
> On Wed, Jul 9, 2008 at 4:54 PM, Darren Dale <dsd...@gm...> wrote:
> > On Wednesday 09 July 2008 10:35:55 am anirudh vij wrote:
> >> Hi,
> >>
> >> First off, I'd like to congratulate the devs who wrote the 3D plotting
> >> module. Its great and fits a lot of my plotting needs without
> >> resorting to vtk, mayavi etc.
> >>
> >> But I've had some issues with 3D plots
> >
> > I'm sorry to disappoint, but 3D plotting has been unsupported for a long
> > time and was recently removed from the mpl codebase.
>
> This is horrible. How do I do 3D plots now?
> Mayavi svn crashes when called from python.
We have been warning that 3D plotting was unsupported and needed someone to 
volunteer to maintain it for quite a while now. Nobody answered the call, and 
3d capabilities did not survive the transition to the new transforms in 
mpl-0.98, so it was removed, However...
[...]
> matplotlib version is 0.91.2, straight from ubuntu repos.
3D support should still be present in 0.91.x. I just did a clean install of 
0.91.4 from svn, and this works:
import pylab as p
import matplotlib.axes3d as p3
fig=p.figure()
ax = p3.Axes3D(fig)
p.show()
I haven't used matplotlib's 3d capabilities, so I dont know how you expected 
to work with "from pylab import *" instead of the above. Perhaps you could 
give a short explicit example of what used to work and now does not.
Darren
From: Darren D. <dsd...@gm...> - 2008年07月09日 14:55:03
On Wednesday 09 July 2008 10:35:55 am anirudh vij wrote:
> Hi,
>
> First off, I'd like to congratulate the devs who wrote the 3D plotting
> module. Its great and fits a lot of my plotting needs without
> resorting to vtk, mayavi etc.
>
> But I've had some issues with 3D plots
I'm sorry to disappoint, but 3D plotting has been unsupported for a long time 
and was recently removed from the mpl codebase.
> 1. If i do a
> ----
> import pylab as p
> import matplotlib.axes3d as p3
> fig=p.figure()
> ax = p3.Axes3D(fig)
> ax.scatter3D(ravel(x),ravel(y),ravel(z))
> ax.set_xlabel('X')
> ax.set_ylabel('Y')
> ax.set_zlabel('Z')
> p.show()
> ----
>
> then things work well.
probably because you have an old version of axes3d.py in your installation 
directory...
> But if I do an "from pylab import *",
> the plot command does'nt work. Any ideas?
... but pylab.py knows that we dropped 3d support so it doesnt try to import 
it anymore. 
Darren
From: anirudh v. <ani...@gm...> - 2008年07月09日 14:35:57
Hi,
First off, I'd like to congratulate the devs who wrote the 3D plotting
module. Its great and fits a lot of my plotting needs without
resorting to vtk, mayavi etc.
But I've had some issues with 3D plots
1. If i do a
----
import pylab as p
import matplotlib.axes3d as p3
fig=p.figure()
ax = p3.Axes3D(fig)
ax.scatter3D(ravel(x),ravel(y),ravel(z))
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
p.show()
----
then things work well.
But if I do an "from pylab import *",
the plot command does'nt work. Any ideas?
2. In the scatterplot, as well as other 3D plots, I would like to plot
different datasets with different colors. While in plot(), "r." etc
change color, in plot3d etc the option does'nt work.
So, is there a way to use different colors in the same plot.
3. Is there any documentation on the 3D plotting functions. There are
examples at http://scipy.org/Cookbook/Matplotlib/mplot3D, but I
could'nt find any documentation on function calls, options etc.
help(plot3d) just says plot3d(**args) without any other info.
cheers,
anirudh.
From: Marjolaine R. <mro...@cs...> - 2008年07月09日 13:34:28
Hi,
I don't understand how one creates his own colormap. i am using matplotlib and I have checked the example in http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps but I can't really understand how it works. Are there any other examples out there? I want to create a colormap a bit like the one at this url:
http://www.pyngl.ucar.edu/Graphics/Images/ViBlGrWhYeOrRe.gif
best regards, Marjolaine.
-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
From: James K. G. <jk...@sa...> - 2008年07月09日 13:20:08
Thanks for the suggestion, Michael. Reading it led to a bit of a forehead
slap.
Unfortunately, that didn't work either. Curiously, it appears that
the "show()" command does not return.
----- CODE SECTION -------------
#!/usr/local/bin/python
import os,sys
import pylab
def main():
 x = pylab.linspace(-10,10,100)
 y = pylab.sin(x)
 pylab.plot(x,y)
 sys.stderr.write("Begun.")
 pylab.show()
 sys.stderr.write("Done.")
if __name__ == "__main__":
 main()
---- END CODE -------------
When executed from the command line:
$ ./test.py &
 . . . the plot displays; clicking on the X closes it, but the process keeps
on running.
When executed as an argument to python:
$ python test.py &
 . . . the same behavior (except it's a python process which hangs).
The two sys.stderr.write() statements are for debugging. The first one
executes; the second does not. My conclusion is that the show() command does
not return.
----------
When I operate interactively,
 the command "pylab.plot(x,y)" opens a widow labeled "Figure 1".
 . . . then . . .
 the command "show()" writes the plot to that window (i.e., sine plot).
Clicking the X in the figure window causes the window to disappear, but
the "show()" command fails to return.
--------------
So . . . I figure that the lack of show() returning is the root problem.
Any suggestions?
 I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8 from the yum
repository. Backend is set to GTKAgg in my matplotlibrc file.
 James
-------
On Monday 07 July 2008 17:29:16 you wrote:
> Why do you want to "fork" the process? If you just run it in the
> background it should have the desired effect:
>
> <begin tst.py>
> from pylab import *
> x = linspace(-10,10,100) # or load data from a file.
> y = sin(x)
> plot(x,y)
> show()
> <end tst.py>
>
> $ python tst.py&
>
> Process remains in background running until the user closes the plot
> window, at which point it terminates.
>
> Michael.
>
> On 7 Jul 2008, at 2:30 PM, James K. Gruetzner wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > I'm not sure if this is the right venue for this question. I've
> > searched the
> > archives, but without success so far. If this is covered there (or
> > elsewhere
> > on the web), I'd apprciate a pointer to it so it doesn't duplicate
> > bandwidth
> > here.
> >
> > Anyway, what I'd like to do is have a python script which reads
> > data from a
> > file, displays an image/plot/whatever made from the data, and then
> > exits,
> > keeping the image displayed.
> >
> > I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8
> > from the yum
> > repository. Backend is set to GTKAgg in my matplotlibrc file.
> >
> > My initial attempt used the "double fork" method from the python
> > cookbook:
> >
> > - -------------Code follows----------------------
> > if __name__ == "__main__":
> >
> > #From Python Cookbook
> > try:
> > pid = os.fork()
> > if pid > 0:
> > # Exit first parent
> > sys.exit(0)
> > except OSError, e:
> > print >>sys.stderr, "fork #1 failed: %d (%s)" %(e.errno,
> > e.strerror)
> > sys.exit(1)
> >
> > # Decouple from parent environment
> > #os.chdir("/")
> > os.setsid()
> > os.umask(0)
> >
> > # Do second fork
> > try:
> > pid = os.fork()
> > if pid > 0:
> > # Exit from second parent; print eventual PID before exiting
> > print "Image PID %d" % pid
> > sys.exit(0)
> > except OSError, e:
> > print >>sys.stderr, "fork #2 failed: %d (%s)"%(e.errno,
> > e.strerror)
> > sys.exit(1)
> >
> > # Start the main loop to display image
> > main()
> >
> > - --------------END CODE--------------------------------------
> >
> > The main() function reads the values appropriately into the
> > variable "myarr",
> > and then calls imshow and show:
> >
> > - ------------ Code follows -------------------
> >
> >
> > pylab.imshow(myarr)
> > pylab.show()
> > - --------------END CODE--------------------------------------
> >
> > . . . and then exits.
> >
> > All works well until I try to kill the figure/image by clicking on
> > the X in
> > the upper-right corner. It disappears alright, but the process
> > remains
> > running, and I have to manually kill it with the kill -SIGTERM
> > <pid> command.
> >
> > I'd like the process to die when I close the window.
> >
> > I'm really an application programmer, not a system programmer, and
> > usually
> > don't delve this deeply into process management, so I'm probably doing
> > something extremely ignorant. Help is appreciated.
> >
> > Thanks!
> >
> > James
> >
> >
-------------------------------------------------------
From: Maxime B. <max...@ob...> - 2008年07月09日 11:44:23
Tahnk you for the link.
In fact, I don't know what's happen yesterday because I can't reproduce 
the error. I launch again my program and everything is good, I don't 
have the error anymore...
Cheers,
Maxime
Michael Droettboom a écrit :
> Have a look here for some information about memory leaks:
>
> http://matplotlib.sourceforge.net/faq.html#LEAKS
>
> Can you provide a small standalone script that reproduces the error? 
> It is possible that the figures are not being destroyed correctly 
> because an extra reference is being held to them or something of that 
> sort.
>
> Cheers,
> Mike
>
> Maxime Bois wrote:
>> Hi all,
>>
>> I have a problem of free memory for image buffer when I use 
>> Matplotlib (the last version on linux).
>> What i'm doing is that I create 4 figures in the same time, I save 
>> my plots and I close them. After that, I create 4 new figures, save 
>> them and close them... I do that many times and after a moment, a 
>> problem occurs.
>> I obtain this message : "<class '_tkinter.TclError'>: not enough 
>> free memory for image buffer" and my program stops.
>>
>> Does anyone have a solution for this problem ?
>> Thanks a lot
>> M.
>>
>> ------------------------------------------------------------------------- 
>>
>> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>> Studies have shown that voting for your favorite open source project,
>> along with a healthy diet, reduces your potential for chronic lameness
>> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
>
From: Eric B. <eri...@gm...> - 2008年07月09日 03:05:52
I need to trigger some data processing* after the user changes the
limits of a plot (e.g., via pan, zoom or the 'home' button). The code
below is my proof-of-concept solution to this problem, which I offer
for discussion and reference. It was a good practice in learning the
events system. I would not be sad if someone were to inform me of more
elegant solution.
Thanks,
Eric
*I'm plotting data points in three separate panels (x-y, x-z, and z-y)
with shared axes. The data processing replots x-z and z-y to match the
data in the x-y view.
class accumulator(object):
 """ Provides for event callbacks for matplotlib drag/release events and
 axis limit changes by accumulating a series of event occurrences.
 Produces a single call to func after a user interacts with the plot.
 Sample usage:
 from pylab import figure, show
 def simple(count):
 print "update ", count
 a = accumulator(simple)
 f=figure()
 ax=f.add_subplot(111)
 plt=ax.plot(range(10))
 f.canvas.mpl_connect('draw_event', a.draw_event)
 f.canvas.mpl_connect('button_release_event', a.mouse_up_event)
 f.canvas.mpl_connect('button_press_event', a.mouse_down_event)
 ax.callbacks.connect('xlim_changed', a.axis_limit_changed)
 ax.callbacks.connect('ylim_changed', a.axis_limit_changed)
 show()
 """
 def __init__(self, func):
 self.func=func
 self.reset()
 self.counter = 0
 self.mouse_up = False
 def reset(self):
 """ Reset flags after the update function is called.
 Mouse is tracked separately.
 """
 self.limits_changed = 0
 self.got_draw = False
 def axis_limit_changed(self, ax):
 self.limits_changed += 1
 self.check_status()
 def draw_event(self, event):
 self.got_draw=True
 self.check_status()
 def mouse_up_event(self, event):
 self.mouse_up = True
 self.check_status()
 def mouse_down_event(self, event):
 self.mouse_up = False
 def both_limits_changed(self):
 """ Both x and y limits changed and the mouse is up (not dragging)
 This condition takes care of the limits being reset outside of a
 dragging context, such as the view-reset (home) button on the
 Matplotlib standard toolbar.
 """
 return (self.limits_changed >= 2) & self.mouse_up
 def interaction_complete(self):
 """ x, y, or both limits changed, and the mouse is up (not dragging).
 Also checks if matplotlib has done its final redraw of the screen,
 which comes after the call to *both* set_xlim and set_ylim
 have been triggered. The check for the draw event is the crucial
 step in not producing two calls to self.func.
 """
 return (self.limits_changed>0) & self.got_draw & self.mouse_up
 def check_status(self):
 if self.both_limits_changed() | self.interaction_complete():
 self.func(self.counter)
 self.reset()
 self.counter += 1

Showing 13 results of 13

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /