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

Showing 14 results of 14

From: Charlie M. <cw...@gm...> - 2006年09月05日 20:57:56
Refer to the top of the setupext.py file.
On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
> Where can I find these mingw instructions? Sorry for asking such a simple
> question but I can not seem to find them, ive googled it looked in the
> readme file and cant find them :/.
>
> ----- Original Message -----
> From: "Charlie Moad" <cw...@gm...>
> To: "Kenny Ortmann" <ya...@em...>
> Cc: "matplotlib-users" <mat...@li...>
> Sent: Tuesday, September 05, 2006 2:45 PM
> Subject: Re: [Matplotlib-users] installation
>
>
> > VS2003.Net is needed to easily build the python 2.4 version. (e.g.
> > python setup.py build) You can also follow the mingw instructions for
> > a more open-source way of building matplotlib for windows. We still
> > have to do this for python 2.3. You can supposedly download the .net
> > compiler tools for free, but I haven't tried. I am pasting my
> > previous post since I didn't re-all.
> >
> >> > In order to build mpl with visual studio it requires VS.Net 2003.
> >> > Python 2.5 will be a little more "open" since it requires VS2005 and
> >> > there is a free edition of VS2005 called "Express Edition". Python
> >> > 2.3 required the version of VS before .Net.
> >
> > - Charlie
> >
> > On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
> >> Do i need to reinstall vs2003.net? I do not have access to that product
> >> anylonger. I tried to obtain the latest SVN and i still recieved the
> >> same
> >> error. Is there a certain way you are supposed to compile mpl on windows
> >> if
> >> you dont use the .exe? for instance do i have to build it first? or
> >> anything like that
> >>
> >>
> >> ----- Original Message -----
> >> From: "Charlie Moad" <cw...@gm...>
> >> To: "Kenny Ortmann" <ya...@em...>
> >> Sent: Tuesday, September 05, 2006 1:21 PM
> >> Subject: Re: [Matplotlib-users] installation
> >>
> >>
> >> > On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
> >> >> Hey Charlie thanks for the info.
> >> >>
> >> >> I went ahead and installed Active Tcl
> >> >> I removed microsft visual studio 2003 .net from my computer because I
> >> >> never
> >> >> used it, and I did not want it on here in the first place but i had it
> >> >> on
> >> >> here from being an intern over the summer.
> >> >
> >> > You can use the new mpl release from today.
> >> >
> >> > In order to build mpl with visual studio it requires VS.Net 2003.
> >> > Python 2.5 will be a little more "open" since it requires VS2005 and
> >> > there is a free edition of VS2005 called "Express Edition". Python
> >> > 2.3 required the version of VS before .Net.
> >> >
> >>
> >>
> >
>
>
From: Kenny O. <ya...@em...> - 2006年09月05日 20:54:25
Where can I find these mingw instructions? Sorry for asking such a simple
question but I can not seem to find them, ive googled it looked in the
readme file and cant find them :/.
----- Original Message -----
From: "Charlie Moad" <cw...@gm...>
To: "Kenny Ortmann" <ya...@em...>
Cc: "matplotlib-users" <mat...@li...>
Sent: Tuesday, September 05, 2006 2:45 PM
Subject: Re: [Matplotlib-users] installation
> VS2003.Net is needed to easily build the python 2.4 version. (e.g.
> python setup.py build) You can also follow the mingw instructions for
> a more open-source way of building matplotlib for windows. We still
> have to do this for python 2.3. You can supposedly download the .net
> compiler tools for free, but I haven't tried. I am pasting my
> previous post since I didn't re-all.
>
>> > In order to build mpl with visual studio it requires VS.Net 2003.
>> > Python 2.5 will be a little more "open" since it requires VS2005 and
>> > there is a free edition of VS2005 called "Express Edition". Python
>> > 2.3 required the version of VS before .Net.
>
> - Charlie
>
> On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
>> Do i need to reinstall vs2003.net? I do not have access to that product
>> anylonger. I tried to obtain the latest SVN and i still recieved the
>> same
>> error. Is there a certain way you are supposed to compile mpl on windows
>> if
>> you dont use the .exe? for instance do i have to build it first? or
>> anything like that
>>
>>
>> ----- Original Message -----
>> From: "Charlie Moad" <cw...@gm...>
>> To: "Kenny Ortmann" <ya...@em...>
>> Sent: Tuesday, September 05, 2006 1:21 PM
>> Subject: Re: [Matplotlib-users] installation
>>
>>
>> > On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
>> >> Hey Charlie thanks for the info.
>> >>
>> >> I went ahead and installed Active Tcl
>> >> I removed microsft visual studio 2003 .net from my computer because I
>> >> never
>> >> used it, and I did not want it on here in the first place but i had it
>> >> on
>> >> here from being an intern over the summer.
>> >
>> > You can use the new mpl release from today.
>> >
>> > In order to build mpl with visual studio it requires VS.Net 2003.
>> > Python 2.5 will be a little more "open" since it requires VS2005 and
>> > there is a free edition of VS2005 called "Express Edition". Python
>> > 2.3 required the version of VS before .Net.
>> >
>>
>>
>
From: Charlie M. <cw...@gm...> - 2006年09月05日 19:45:34
VS2003.Net is needed to easily build the python 2.4 version. (e.g.
python setup.py build) You can also follow the mingw instructions for
a more open-source way of building matplotlib for windows. We still
have to do this for python 2.3. You can supposedly download the .net
compiler tools for free, but I haven't tried. I am pasting my
previous post since I didn't re-all.
> > In order to build mpl with visual studio it requires VS.Net 2003.
> > Python 2.5 will be a little more "open" since it requires VS2005 and
> > there is a free edition of VS2005 called "Express Edition". Python
> > 2.3 required the version of VS before .Net.
- Charlie
On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
> Do i need to reinstall vs2003.net? I do not have access to that product
> anylonger. I tried to obtain the latest SVN and i still recieved the same
> error. Is there a certain way you are supposed to compile mpl on windows if
> you dont use the .exe? for instance do i have to build it first? or
> anything like that
>
>
> ----- Original Message -----
> From: "Charlie Moad" <cw...@gm...>
> To: "Kenny Ortmann" <ya...@em...>
> Sent: Tuesday, September 05, 2006 1:21 PM
> Subject: Re: [Matplotlib-users] installation
>
>
> > On 9/5/06, Kenny Ortmann <ya...@em...> wrote:
> >> Hey Charlie thanks for the info.
> >>
> >> I went ahead and installed Active Tcl
> >> I removed microsft visual studio 2003 .net from my computer because I
> >> never
> >> used it, and I did not want it on here in the first place but i had it on
> >> here from being an intern over the summer.
> >
> > You can use the new mpl release from today.
> >
> > In order to build mpl with visual studio it requires VS.Net 2003.
> > Python 2.5 will be a little more "open" since it requires VS2005 and
> > there is a free edition of VS2005 called "Express Edition". Python
> > 2.3 required the version of VS before .Net.
> >
>
>
From: Eric F. <ef...@ha...> - 2006年09月05日 18:05:41
Karl Edler wrote:
> Hello,
> 
> I am trying to construct a contour plot where the contours are separated 
> by a constant amount but I would like a color bar (or something) to show 
> what the values of the different levels are. I will have too many 
> contours for clabels to be effective.
> 
> When I use colorbar with unequally spaced contours and use 
> cspacing='linear' the ticks are spaced nicely but the colors are not.
Karl,
This was fixed some time ago with completely new colorbar code, 
including a change in the API. Attached are a modification of your test 
program to suit the API (and make a smaller png file for this email), 
and the result.
Eric
From: Kenny O. <ya...@em...> - 2006年09月05日 18:02:21
Hey Charlie thanks for the info.
I went ahead and installed Active Tcl
I removed microsft visual studio 2003 .net from my computer because I never
used it, and I did not want it on here in the first place but i had it on
here from being an intern over the summer.
C:\matplotlib\trunk\matplotlib>c:\Python24\python.exe setup.py install
GTK requires pygtk
building tkagg 2 4
 Building for python24
GTKAgg requires pygtk
running install
running build
running build_py
running build_ext
No module named msvccompiler in numpy.distutils, trying from distutils..
building 'matplotlib.backends._tkagg' extension
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo
/Ox
 /MD /W3 /GX
/DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc -Iswig -Iagg23/incl
ude -I. -I. -Iwin32_static/include/tcl84\freetype2 -I.\freetype2
-Isrc\freetype2
 -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2 -I.\freetype2
-Ic:\Pyt
hon24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp
/Fobuild\temp.win32-2.4\Release
\src/_tkagg.obj
_tkagg.cpp
src\_tkagg.cpp(28) : fatal error C1083: Cannot open include file: 'tk.h': No
suc
h file or directory
error: Command ""C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\cl.e
xe" /c /nologo /Ox /MD /W3 /GX
/DNDEBUG -Iwin32_static/include/tcl84 -I. -Isrc -
Iswig -Iagg23/include -I. -I. -Iwin32_static/include/tcl84\freetype2
-I.\freetyp
e2 -Isrc\freetype2 -Iswig\freetype2 -Iagg23/include\freetype2 -I.\freetype2
-I.\
freetype2 -Ic:\Python24\include -Ic:\Python24\PC /Tpsrc/_tkagg.cpp
/Fobuild\temp
.win32-2.4\Release\src/_tkagg.obj" failed with exit status 2
This is the error i got after my first try at
python setup.py install
after it did not work is when i uninstalled .net 2003. and i recieve this
error currently.
C:\matplotlib\trunk\matplotlib>c:\Python24\python.exe setup.py install
GTK requires pygtk
building tkagg 2 4
 Building for python24
GTKAgg requires pygtk
running install
running build
running build_py
running build_ext
No module named msvccompiler in numpy.distutils, trying from distutils..
error: The .NET Framework SDK needs to be installed before building
extensions f
or Python.
Has anyone seen this one? I would not be so persistent as to trying to
install the current SVN except that I need one of the algorithms in numpy
version 1.0b2 and above.
I am also going to post this on the numpy mailing list because it says the
error is in numpy.distutils.
>
> You need to install the tcl/tk headers as Darren mentioned. I just
> install ActiveTcl and the build should pick up on it no problem.
>
From: Eric F. <ef...@ha...> - 2006年09月05日 18:01:33
Davidlohr Bueso A. wrote:
> Hi,
> 
> I am having trouble graphing constant functions in matplotlib (a simple
> y = 2). Here is a simple test script I'm using:
> 
> from pylab import *
> 
> def f(x):
> return 2
Try return 2*ones(shape(x))
The problem is that you are returning a scalar, not an array the same 
size as x; mpl plots arrays, not scalars.
Eric
From: Matt <cre...@ya...> - 2006年09月05日 18:01:32
Use this to plot it:
plot([x], [f(x)]) you need the square brackets.
-Matt
--- "Davidlohr Bueso A." <db...@li...> wrote:
> Hi,
> 
> I am having trouble graphing constant functions in
> matplotlib (a simple
> y = 2). Here is a simple test script I'm using:
> 
> from pylab import *
> 
> def f(x):
> return 2
> 
> x = arange(1, 4)
> 
> plot(x, f(x))
> show()
> 
> When I run it, I get this error:
> 
> Traceback (most recent call last):
> File "test", line 8, in ?
> plot(x, f(x))
> File
>
"/usr/lib/python2.4/site-packages/matplotlib/pylab.py",
> line
> 2019, in plot
> ret = gca().plot(*args, **kwargs)
> File
>
"/usr/lib/python2.4/site-packages/matplotlib/axes.py",
> line 2106,
> in plot
> for line in self._get_lines(*args, **d):
> File
>
"/usr/lib/python2.4/site-packages/matplotlib/axes.py",
> line 304,
> in _grab_next_args
> yield self._plot_2_args(remaining, **kwargs)
> File
>
"/usr/lib/python2.4/site-packages/matplotlib/axes.py",
> line 253,
> in _plot_2_args
> assert(iterable(y))
> AssertionError
> 
> 
> Could anyone tell me what I'm doing wrong (I'm new
> to matplotlib btw)?
> 
> Thanks!
> 
>
-------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support
> web services, security?
> Get stuff done quickly with pre-integrated
> technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1
> based on Apache Geronimo
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
From: Davidlohr B. A. <db...@li...> - 2006年09月05日 17:53:05
Hi,
I am having trouble graphing constant functions in matplotlib (a simple
y = 2). Here is a simple test script I'm using:
from pylab import *
def f(x):
 return 2
x = arange(1, 4)
plot(x, f(x))
show()
When I run it, I get this error:
Traceback (most recent call last):
 File "test", line 8, in ?
 plot(x, f(x))
 File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line
2019, in plot
 ret = gca().plot(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 2106,
in plot
 for line in self._get_lines(*args, **d):
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 304,
in _grab_next_args
 yield self._plot_2_args(remaining, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 253,
in _plot_2_args
 assert(iterable(y))
AssertionError
Could anyone tell me what I'm doing wrong (I'm new to matplotlib btw)?
Thanks!
From: Matt <cre...@ya...> - 2006年09月05日 16:31:09
I had a quick question about the pylab package. When
I use the plot function the first time, it works
great. However, upon closing the window and plotting
a second figure, I immediately get a microsoft visual
c++ runtime error when trying to close or move this
figure.
If I plot one figure, and attempt to plot a second
figure, the whole program crashes. Also, I am working
in pythonwin.
Thanks in advance,
Matt
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
From: Charlie M. <cw...@gm...> - 2006年09月05日 15:58:53
Minor rev bump for numpy 1.0b5 compatibility. This release should
remain compatible with future 1.0 releases of numpy.
http://cheeseshop.python.org/pypi/matplotlib/
http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474
===============================================================
2006年09月05日 Released 0.87.5 at revision 2761
2006年09月04日 Added nxutils for some numeric add-on extension code --
		 specifically a better/more efficient inside polygon tester (see
		 unit/inside_poly_*.py) - JDH
2006年09月04日 Made bitstream fonts the rc default - JDH
2006年08月31日 Fixed alpha-handling bug in ColorConverter, affecting
 collections in general and contour/contourf in
 particular. - EF
2006年08月30日 ft2font.cpp: Added draw_rect_filled method (now used by mathtext2
 to draw the fraction bar) to FT2Font - ES
2006年08月29日 setupext.py: wrap calls to tk.getvar() with str(). On some
 systems, getvar returns a Tcl_Obj instead of a string - DSD
2006年08月28日 mathtext2.py: Sub/superscripts can now be complex (i.e.
 fractions etc.). The demo is also updated - ES
2006年08月28日 font_manager.py: Added /usr/local/share/fonts to list of
 X11 font directories - DSD
2006年08月28日 mahtext2.py: Initial support for complex fractions. Also,
 rendering is now completely separated from parsing. The
 sub/superscripts now work better.
 Updated the mathtext2_demo.py - ES
2006年08月27日 qt backends: don't create a QApplication when backend is
 imported, do it when the FigureCanvasQt is created. Simplifies
 applications where mpl is embedded in qt. Updated
 embedding_in_qt* examples - DSD
2006年08月27日 mahtext2.py: Now the fonts are searched in the OS font dir and
 in the mpl-data dir. Also env is not a dict anymore. - ES
2006年08月26日 minor changes to __init__.py, mathtex2_demo.py. Added matplotlibrc
 key "mathtext.mathtext2" (removed the key "mathtext2") - ES
2006年08月21日 mathtext2.py: Initial support for fractions
 Updated the mathtext2_demo.py
 _mathtext_data.py: removed "\" from the unicode dicts
 mathtext.py: Minor modification (because of _mathtext_data.py)- ES
2006年08月20日 Added mathtext2.py: Replacement for mathtext.py. Supports _ ^,
 \rm, \cal etc., \sin, \cos etc., unicode, recursive nestings,
 inline math mode. The only backend currently supported is Agg
 __init__.py: added new rc params for mathtext2
 added mathtext2_demo.py example - ES
2006年08月19日 Added embedding_in_qt4.py example - DSD
2006年08月11日 Added scale free Ellipse patch for Agg - CM
2006年08月10日 Added converters to and from julian dates to matplotlib.dates
 (num2julian and julian2num) - JDH
2006年08月08日 Fixed widget locking so multiple widgets could share the
 event handling - JDH
2006年08月07日 Added scale free Ellipse patch to SVG and PS - CM
2006年08月05日 Re-organized imports in numerix for numpy 1.0b2 -- TEO
2006年08月04日 Added draw_markers to PDF backend. - JKS
2006年08月01日 Fixed a bug in postscript's rendering of dashed lines - DSD
2006年08月01日 figure.py: savefig() update docstring to add support for 'format'
 argument.
 backend_cairo.py: print_figure() add support 'format' argument. - SC
2006年07月31日 Don't let postscript's xpdf distiller compress images - DSD
2006年07月31日 Added shallowcopy() methods to all Transformations;
 removed copy_bbox_transform and copy_bbox_transform_shallow
 from transforms.py;
 added offset_copy() function to transforms.py to
 facilitate positioning artists with offsets.
 See examples/transoffset.py. - EF
2006年07月31日 Don't let postscript's xpdf distiller compress images - DSD
2006年07月29日 Fixed numerix polygon bug reported by Nick Fotopoulos.
 Added inverse_numerix_xy() transform method.
 Made autoscale_view() preserve axis direction
 (e.g., increasing down).- EF
2006年07月28日 Added shallow bbox copy routine for transforms -- mainly
 useful for copying transforms to apply offset to. - JDH
2006年07月28日 Added resize method to FigureManager class
 for Qt and Gtk backend - CM
2006年07月28日 Added subplots_adjust button to Qt backend - CM
2006年07月26日 Use numerix more in collections.
 Quiver now handles masked arrays. - EF
2006年07月22日 Fixed bug #1209354 - DSD
2006年07月22日 make scatter() work with the kwarg "color". Closes bug
 1285750 - DSD
2006年07月20日 backend_cairo.py: require pycairo 1.2.0.
 print_figure() update to output SVG using cairo.
2006年07月19日 Added blitting for Qt4Agg - CM
2006年07月19日 Added lasso widget and example examples/lasso_demo.py - JDH
2006年07月18日 Added blitting for QtAgg backend - CM
2006年07月17日 Fixed bug #1523585: skip nans in semilog plots - DSD
2006年07月12日 Add support to render the scientific notation label
 over the right-side y-axis - DSD
From: Karl E. <kt...@ma...> - 2006年09月05日 15:58:01
Attachments: BadColorBar.png
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
 <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<br>
<br>
I am trying to construct a contour plot where the contours are
separated by a constant amount but I would like a color bar (or
something) to show what the values of the different levels are. I will
have too many contours for clabels to be effective.<br>
<br>
When I use colorbar with unequally spaced contours and use
cspacing='linear' the ticks are spaced nicely but the colors are not.<br>
<br>
The following code exemplifies the problem:<br>
<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(128, 128, 128);"><i>#!/usr/bin/python</i></span>
<span style="color: rgb(255, 0, 255);">from</span> pylab <span
 style="color: rgb(255, 0, 255);">import</span> <span
 style="color: rgb(255, 0, 255);">*</span>
<span style="color: rgb(128, 128, 128);"><i>#Compute Data</i></span>
delta <span
 style="color: rgb(255, 0, 255);">=</span> <span
 style="color: rgb(128, 0, 128);">0.025</span>
x <span
 style="color: rgb(255, 0, 255);">=</span> arange<span
 style="color: rgb(255, 0, 255);">(-</span><span
 style="color: rgb(128, 0, 128);">3.0</span>, <span
 style="color: rgb(128, 0, 128);">3.0</span>, delta<span
 style="color: rgb(255, 0, 255);">)</span>
y <span
 style="color: rgb(255, 0, 255);">=</span> arange<span
 style="color: rgb(255, 0, 255);">(-</span><span
 style="color: rgb(128, 0, 128);">2.0</span>, <span
 style="color: rgb(128, 0, 128);">2.0</span>, delta<span
 style="color: rgb(255, 0, 255);">)</span>
X, Y <span
 style="color: rgb(255, 0, 255);">=</span> meshgrid<span
 style="color: rgb(255, 0, 255);">(</span>x, y<span
 style="color: rgb(255, 0, 255);">)</span>
Z1 <span
 style="color: rgb(255, 0, 255);">=</span> bivariate_normal<span
 style="color: rgb(255, 0, 255);">(</span>X, Y, <span
 style="color: rgb(128, 0, 128);">1.0</span>, <span
 style="color: rgb(128, 0, 128);">1.0</span>, <span
 style="color: rgb(128, 0, 128);">0.0</span>, <span
 style="color: rgb(128, 0, 128);">0.0</span><span
 style="color: rgb(255, 0, 255);">)</span>
Z2 <span
 style="color: rgb(255, 0, 255);">=</span> bivariate_normal<span
 style="color: rgb(255, 0, 255);">(</span>X, Y, <span
 style="color: rgb(128, 0, 128);">1.5</span>, <span
 style="color: rgb(128, 0, 128);">0.5</span>, <span
 style="color: rgb(0, 0, 255);">1</span>, <span
 style="color: rgb(0, 0, 255);">1</span><span
 style="color: rgb(255, 0, 255);">)</span>
<span style="color: rgb(128, 128, 128);"><i># difference of Gaussians</i></span>
Z <span
 style="color: rgb(255, 0, 255);">=</span> <span
 style="color: rgb(128, 0, 128);">100.0</span> <span
 style="color: rgb(255, 0, 255);">*</span> <span
 style="color: rgb(255, 0, 255);">(</span>Z2 <span
 style="color: rgb(255, 0, 255);">-</span> Z1<span
 style="color: rgb(255, 0, 255);">)</span>
<span style="color: rgb(128, 128, 128);"><i>#Draw figure</i></span>
figure<span
 style="color: rgb(255, 0, 255);">()</span>
levels<span
 style="color: rgb(255, 0, 255);">=[-</span><span
 style="color: rgb(0, 0, 255);">9</span>,<span
 style="color: rgb(255, 0, 255);">-</span><span
 style="color: rgb(128, 0, 128);">7.5</span>,<span
 style="color: rgb(255, 0, 255);">-</span><span
 style="color: rgb(0, 0, 255);">5</span>,<span
 style="color: rgb(255, 0, 255);">-</span><span
 style="color: rgb(128, 0, 128);">2.5</span>,<span
 style="color: rgb(255, 0, 255);">-</span><span
 style="color: rgb(128, 0, 128);">0.5</span>,<span
 style="color: rgb(128, 0, 128);">0.5</span>,<span
 style="color: rgb(128, 0, 128);">2.5</span>,<span
 style="color: rgb(0, 0, 255);">5</span>,<span
 style="color: rgb(128, 0, 128);">7.5</span>,<span
 style="color: rgb(0, 0, 255);">9</span><span
 style="color: rgb(255, 0, 255);">]</span>
CS <span
 style="color: rgb(255, 0, 255);">=</span> contour<span
 style="color: rgb(255, 0, 255);">(</span>Z, levels,
 origin<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(221, 0, 0);">'lower'</span>,
 linewidths<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(0, 0, 255);">2</span>,
 extent<span
 style="color: rgb(255, 0, 255);">=(-</span><span
 style="color: rgb(0, 0, 255);">3</span>,<span
 style="color: rgb(0, 0, 255);">3</span>,<span
 style="color: rgb(255, 0, 255);">-</span><span
 style="color: rgb(0, 0, 255);">2</span>,<span
 style="color: rgb(0, 0, 255);">2</span><span
 style="color: rgb(255, 0, 255);">))</span>
clabel<span
 style="color: rgb(255, 0, 255);">(</span>CS,
 inline<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(0, 0, 255);">1</span>,
 fmt<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(221, 0, 0);">'%1.1f'</span>,
 fontsize<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(0, 0, 255);">14</span><span
 style="color: rgb(255, 0, 255);">)</span>
colorbar<span
 style="color: rgb(255, 0, 255);">(</span>CS,cspacing<span
 style="color: rgb(255, 0, 255);">=</span><span
 style="color: rgb(221, 0, 0);">'linear'</span><span
 style="color: rgb(255, 0, 255);">)</span> <span
 style="color: rgb(128, 128, 128);"><i># make a colorbar for the contour lines</i></span>
title<span
 style="color: rgb(255, 0, 255);">(</span><span
 style="color: rgb(221, 0, 0);">"ColorBar lines don't match ticks"</span><span
 style="color: rgb(255, 0, 255);">)</span>
savefig<span
 style="color: rgb(255, 0, 255);">(</span><span
 style="color: rgb(221, 0, 0);">'BadColorBar'</span><span
 style="color: rgb(255, 0, 255);">)</span>
show<span
 style="color: rgb(255, 0, 255);">()</span>
</pre>
<br>
I have attached the file 'BadColorBar.png'<br>
<br>
Any help would be appreciated,<br>
Karl Edler<br>
</body>
</html>
From: Christian M. <mee...@un...> - 2006年09月05日 13:47:46
Hi
In one somewhat bigger application of mine, which makes use of matplotlib, it 
can happen that a user can assign a name to a dataset, which latex in turn is 
unable to process as part of the legend. Of course it is possible to prevent 
the user from doing so in most cases, but still it is possible that a 
RuntimeError is raised.
My actual problem now is that there is no way to figure out where the 
exception was thrown by means of simply following the traceback, because the 
traceback is only about the matplotlib code. Or with other words: The 
traceback shows only where the problem in the matplotlib code is, e.g.
Traceback (most recent call last):
 File "/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_wx.py", 
line 1048, in _onPaint
 self.draw(repaint=False)
<snip most of the Traceback>
File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line 197, 
in make_dvi
 if exit_status: raise RuntimeError('LaTeX was not able to process \
RuntimeError: LaTeX was not able to process the flowing string:
<<some string>>
Here is the full report generated by LaTeX:
etc. etc. etc.
Alright, this particular error was provoked and for a small script it will be 
easy to figure out where the string in question was passed to latex, but I 
hope I was able to make myself clear.
Is it feasible to get a future release of matplotlib to include the individual 
programmers code where the exception was triggered into the traceback? (Or 
did I accidently truncate this very part of a traceback somehow?)
Regards,
Christian
PS I guess it should read:
"LaTeX was not able to process the following string" instead of "flowing 
string", right?
PPS Guess I should mention too, that I don't use the most recent version of 
mpl, but '0.87.3'.
From: Jon Roadley-B. <jon...@gm...> - 2006年09月05日 06:05:36
I have a solution that works.
The problem is in 1/2 GTK and threads. unfortunetly threads are needed in
this instance, idle timers [orig tried with them] have their issues which
added their own problems, threads gave alot more benefits then they then
problems they solved (I have a forum-thread on a python forum about three
methods I tried, for this instance threading is the only solution)
Basically GTK can work with threads, the problem arrises when the thread
want's to change the GUI (say a txt lable). GTK can be made "thread-safe"
via calling gtk.gdk.threads_init() before gtk.main(). THEN every time the
thread wants to change something, put it between
gtk.threads_enter()
gtk.threads_leave()
calls.
THIS only works for default GTK widgets and since a matplotlib window isn't
a standard GTK widget it hard-locks the GUI.
I have a solution to it, it is quite neat (it could be a fn wrapper, but
don't know much abt fn wrappers)
#!/usr/bin/env python
import threading
import time
import math
import sys
import os
import pygtk
if sys.platform == 'win32':
 os.environ['PATH'] += ';lib;'
else:
 pygtk.require('2.0')
import gtk
import gobject
assert gtk.pygtk_version >= (1,99,16), 'pygtk should be >= 1.99.16'
#import gtk.glade
from pylab import *
rcParams['numerix'] = 'numpy'
import matplotlib
matplotlib.use('GTK')
from matplotlib.figure import Figure
from matplotlib.axes import Subplot
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
TIME = range(360)
VOLT = [math.sin(math.radians(x)) for x in TIME]
VOLT2 = [2]*360
VOLT3 = [x for x in range(360)]
def do_gui(fn,*args,**kw):
 def idle_func():
 print "idle"
 gtk.threads_enter()
 try:
 fn(*args,**kw)
 finally:
 gtk.threads_leave()
 gobject.idle_add(idle_func)
class my_thread(threading.Thread):
 def __init__(self,GUI):
 super(my_thread, self).__init__()
 self.GUI = GUI
 def run(self):
 time.sleep(10)
 #gtk.threads_enter()
 #try:
 # self.GUI.Graph([TIME,VOLT3])
 #finally:
 # gtk.threads_leave()
 do_gui(self.GUI.Graph,[TIME,VOLT3])
gtk.gdk.threads_init()
class GUI(object):
 def GUI_Plot(self,widget,event,data=None):
 self.Graph([TIME,VOLT2])
 def delete_event(self,widget,event,data=None):
 return False
 def destroy(self,widget,data=None):
 gtk.main_quit()
 def __init__(self):
 super(GUI,self).__init__()
 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 self.window.set_title("Matplotlib GTK test")
 self.window.connect("delete_event",self.delete_event)
 self.window.connect("destroy",self.destroy)
 self.window.set_border_width(10)
 self.box1 = gtk.VBox(False,0)
 self.window.add(self.box1)
 self.button = gtk.Button("GUI Plot")
 self.button.connect("clicked",self.GUI_Plot,None)
 self.box1.pack_start(self.button,True,True,0)
 self.button.show()
 self.box1.show()
 self.window.show()
 self.Graph([TIME,VOLT])
 def Graph(self,DATA):
 try:
 self.canvas.destroy()
 self.toolbar.destroy()
 except:pass
 self.figure = Figure(figsize=(6,3), dpi=100)#{{{
 self.axis = self.figure.add_subplot(111)
 self.axis.grid(True)
 self.axis.set_xlabel('Time (s)')
 self.axis.plot(DATA[0],DATA[1],linewidth=2.0)
 self.canvas = FigureCanvas(self.figure) # a gtk.DrawingArea
 self.canvas.show()
 self.graphview = self.box1
 self.graphview.pack_start(self.canvas, True, True)
 def main(self):
 gtk.main()
if __name__ == "__main__":
 A = GUI()
 B = my_thread(A)
 B.start()
 gtk.threads_enter()
 A.main()
 gtk.threads_leave()
basically another fn is created that has the threads_enter and threads_leave
called, BUT they themselves are called within a gtk-idle call, this stops
the GUI from hard-locking.
I don't know if it is the best solution, but it is a solution.
thanks
On 9/5/06, John Hunter <jdh...@ac...> wrote:
>
> >>>>> "Jon" == Jon Roadley-Battin <jon...@gm...> writes:
> Jon> is there any thread_init for matplotlib. short of having a
> Jon> timer within the GUI class that checks if any new data is
> Jon> present I cant see a way around this. It has to be done this
>
> There isn't any such method. Would it work for you to update your
> line data / plot data and run canvas.draw_idle in a gtk timer, eg
> every second? Since you are only polling your RS232 every second or
> so, it seems like you could update your graph in a timer on roughly
> the same time scale w/o too much pain.
>
> I don't know mcuh about threading, but trying to make threads play
> nice with all the GUIs mpl supports seems daunting, and I prefer to
> offload that to external apps -- eg ipython in pylab mode. But if
> there is something we can add that will make your use case work better
> if the timer route doesn't work, feel free to suggest something...
>
> JDH
>
From: John H. <jdh...@ac...> - 2006年09月05日 02:16:50
>>>>> "Jon" == Jon Roadley-Battin <jon...@gm...> writes:
 Jon> is there any thread_init for matplotlib. short of having a
 Jon> timer within the GUI class that checks if any new data is
 Jon> present I cant see a way around this. It has to be done this
There isn't any such method. Would it work for you to update your
line data / plot data and run canvas.draw_idle in a gtk timer, eg
every second? Since you are only polling your RS232 every second or
so, it seems like you could update your graph in a timer on roughly
the same time scale w/o too much pain.
I don't know mcuh about threading, but trying to make threads play
nice with all the GUIs mpl supports seems daunting, and I prefer to
offload that to external apps -- eg ipython in pylab mode. But if
there is something we can add that will make your use case work better
if the timer route doesn't work, feel free to suggest something...
JDH

Showing 14 results of 14

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 によって変換されたページ (->オリジナル) /