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

Showing 12 results of 12

From: Eric F. <ef...@ha...> - 2006年06月16日 22:54:49
John,
Something like this might be what you want:
from pylab import *
import matplotlib.numerix.ma as ma
import matplotlib.colors as colors
xx = rand(10,15)
xxx = (xx*15 - 5).astype(Int)
xxx = ma.masked_where(xxx < 0, xxx)
xxx.set_fill_value(-1) #(not necessary)
cmap = colors.ListedColormap(('r', 'g', 'b',
 'c', 'y', 'm',
 'k', '0.3', '0.5',
 '0.7'))
#cmap.set_bad((1,1,1,0)) # setting alpha to zero does not work, at least
 # for imshow
im = imshow(xxx, interpolation='nearest',
 cmap=cmap, norm=colors.no_norm())
cb = colorbar(shrink=0.6)
What we are doing here is making a custom colormap from a list of colors 
(using any valid mpl color specification), and then indexing directly 
into it with values from a (masked) integer array. Note the use of 
"norm=colors.no_norm()" so that the array values are passed directly to 
the colormap as integers.
Caution: the colorbar command works correctly in this example only with 
the modifications that I committed to svn a few minutes ago.
As noted, the masked regions will have a specified color; they will not 
be transparent. If you need transparent masked regions, then try pcolor 
instead of imshow. Pcolor plots nothing at all in masked cells. 
Pcolormesh, on the other hand, is like imshow in plotting the assigned 
bad color and in using a single alpha for everything.
Eric
John Pye wrote:
> Hi all
> 
> I have some data with enumerated values in an array. Values are like
> 1,2,7,9 spread around in the array. I want to plot those values so that
> I can see the 'regions' in my data, then I want to overlay this with
> some contour lines drawn from other data.
> 
> I want to be able to specify the colors for each of the enumerated
> values, as they need to be consistent throughout my work. My array of
> enumerated values is *masked* so that there are areas where I don't want
> to show anything (this would plot as transparent pixels).
> 
> Has anyone got suggestions on the best way of doing this? It seems that
> the technique in
> http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values
> might be overkill, right? It also seemed that it had some problems with
> masked arrays.
> 
> Cheers
> 
> JP
> 
From: Ryan K. <rya...@gm...> - 2006年06月16日 16:18:02
It seems like no one has any comments on our plans concerning the
exponent fonts. Can you outline for me what it would take to fix
this? If it is fairly simple I may take a crack at it.
Ryan
On 6/14/06, Darren Dale <dd...@co...> wrote:
> I agree that this little experiment of trying to work around latex's
> limitations has been too much trouble. I suggest we go back to the old
> behavior, and anyone who wants sans-serif fonts in their exponents can use
> regular mathtext. I'm hopeful that Edin can make some strides with mpl's
> mathtext support, and in the meantime, people should get decent results if
> they set ps.useafm : True in their rc settings.
>
> Comments?
>
>
> On Wednesday 14 June 2006 19:53, Ryan Krauss wrote:
> > (Sorry, I submitted this email with a real figure instead of a toy
> > example and the file size was too big and it awaits moderator
> > approval).
> >
> > I am afraid I asked you to open a can of worms and now I don't know
> > what we should do. With my font size settings, \small looks to small
> > for the exponents. I tried \normalsize and actually got decent
> > results with \large (replacing all occurances of \small in your
> > ticker.py). See that attached file. But if \small looked good with
> > your settings, I am afraid things are now dependent on the font
> > settings in the rc file as far as what should go in the latex command
> > for the exponents.
> >
> > I remember that this problem came up because I complained about serif
> > fonts in my exponents and we were having a hard time making tex use
> > sans serif math fonts.
> >
> > Maybe the best solution is for me to go back in time and retract that
> > complaint.
> >
> > I don't know. Sorry about the mess this had made. I have plots I am
> > fairly happy with (I will poke around in my rc file and see if I can
> > find out why my x and y axis fonts look different).
> >
> > Ryan
> >
> > On 6/14/06, Ryan Krauss <rya...@gm...> wrote:
> > > I am afraid I asked you to open a can of worms and now I don't know
> > > what we should do. With my font size settings, \small looks to small
> > > for the exponents. I tried \normalsize and actually got decent
> > > results with \large (replacing all occurances of \small in your
> > > ticker.py). See that attached file. But if \small looked good with
> > > your settings, I am afraid things are now dependent on the font
> > > settings in the rc file as far as what should go in the latex command
> > > for the exponents.
> > >
> > > I remember that this problem came up because I complained about serif
> > > fonts in my exponents and we were having a hard time making tex use
> > > sans serif math fonts.
> > >
> > > Maybe the best solution is for me to go back in time and retract that
> > > complaint.
> > >
> > > I don't know. Sorry about the mess this had made. I have plots I am
> > > fairly happy with (I will poke around in my rc file and see if I can
> > > find out why my x and y axis fonts look different).
> > >
> > > Ryan
> > >
> > > On 6/14/06, Ryan Krauss <rya...@gm...> wrote:
> > > > I feel bad that I caused this problem and am now asking you to fix it.
> > > >
> > > > Ryan
> > > >
> > > > On 6/14/06, Darren Dale <dd...@co...> wrote:
> > > > > This is an artifact that was introduced when I tried to give you
> > > > > support for sans-serif fonts in the exponent. Try the attached
> > > > > ticker.py, it wraps the exponent in {\small}. Let me know if this is
> > > > > acceptable, and I'll commit it.
> > > > >
> > > > > On Wednesday 14 June 2006 19:14, Ryan Krauss wrote:
> > > > > > I still have the problem with large exponents with your
> > > > > > matplotlibrc file (but the y-axis plots are no longer different).
> > > > > >
> > > > > > Any thoughts on what I should try next?
> > > > > >
> > > > > > Ryan
> > > > > >
> > > > > > On 6/14/06, Darren Dale <dd...@co...> wrote:
> > > > > > > On Wednesday 14 June 2006 18:51, you wrote:
> > > > > > > > There was a lot of stuff in my tex.cache, but deleting didn't
> > > > > > > > solve my problem.
> > > > > > > >
> > > > > > > > I may have some strange choices for my fonts and font sizes.
> > > > > > > > Can you send me a copy of your matplotlibrc file.
> > > > > > > >
> > > > > > > > Ryan
> > > > > > > >
> > > > > > > > On 6/14/06, Darren Dale <dd...@co...> wrote:
> > > > > > > > > Hi Ryan,
> > > > > > > > >
> > > > > > > > > I'm using the latest svn as well (2479), and I cant reproduce
> > > > > > > > > your problem. Try deleting your tex.cache.
> > > > > > > > >
> > > > > > > > > Darren
> > > > > > > > >
> > > > > > > > > On Wednesday 14 June 2006 18:14, Ryan Krauss wrote:
> > > > > > > > > > I am having a problem with the fonts for exponents on
> > > > > > > > > > semilog plots with usetex.
> > > > > > > > > >
> > > > > > > > > > The attached figure can be generated on my machine with
> > > > > > > > > > figure(1)
> > > > > > > > > > t=arange(0,10,0.01)
> > > > > > > > > > y=sin(2*pi*t)
> > > > > > > > > > semilogx(t,y)
> > > > > > > > > >
> > > > > > > > > > I just upgraded to the latest svn and now the y-axis plots
> > > > > > > > > > look different from the x-axis.
> > > > > > > > > > matplotlib.__version__
> > > > > > > > > > Out[6]: '0.87.3'
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Ryan
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Darren S. Dale, Ph.D.
> > > > > > > > > Cornell High Energy Synchrotron Source
> > > > > > > > > Cornell University
> > > > > > > > > 200L Wilson Lab
> > > > > > > > > Rt. 366 & Pine Tree Road
> > > > > > > > > Ithaca, NY 14853
> > > > > > > > >
> > > > > > > > > dd...@co...
> > > > > > > > > office: (607) 255-9894
> > > > > > > > > fax: (607) 255-9001
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > Matplotlib-users mailing list
> > > > > > > > > Mat...@li...
> > > > > > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > Matplotlib-users mailing list
> > > > > > > > Mat...@li...
> > > > > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> > > > > > >
> > > > > > > --
> > > > > > > Darren S. Dale, Ph.D.
> > > > > > > Cornell High Energy Synchrotron Source
> > > > > > > Cornell University
> > > > > > > 200L Wilson Lab
> > > > > > > Rt. 366 & Pine Tree Road
> > > > > > > Ithaca, NY 14853
> > > > > > >
> > > > > > > dd...@co...
> > > > > > > office: (607) 255-9894
> > > > > > > fax: (607) 255-9001
> > > > >
> > > > > --
> > > > > Darren S. Dale, Ph.D.
> > > > > Cornell High Energy Synchrotron Source
> > > > > Cornell University
> > > > > 200L Wilson Lab
> > > > > Rt. 366 & Pine Tree Road
> > > > > Ithaca, NY 14853
> > > > >
> > > > > dd...@co...
> > > > > office: (607) 255-9894
> > > > > fax: (607) 255-9001
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Matplotlib-users mailing list
> > > > > Mat...@li...
> > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> --
> Darren S. Dale, Ph.D.
> Cornell High Energy Synchrotron Source
> Cornell University
> 200L Wilson Lab
> Rt. 366 & Pine Tree Road
> Ithaca, NY 14853
>
> dd...@co...
> office: (607) 255-9894
> fax: (607) 255-9001
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: John H. <jdh...@ac...> - 2006年06月16日 13:28:56
>>>>> "John" == John Pye <joh...@st...> writes:
 John> I wonder if someone with write access to the scipy wiki
 John> could maybe update the above page with some comments about
 John> the 'mathtext' support in Matplotlib? It might also be worth
 John> noting that the mathtext functionality doesn't support the
 John> \frac operator.
As far as I know, anyone can get write access to the scipy wiki simply
by registering.
From: John P. <joh...@st...> - 2006年06月16日 10:34:14
What I meant to say was that \frac doesn't work for me with the mathtext
renderer, i.e. with usetex=False. Do you find that it *does*?
Cheers
JP
Wolfgang wrote:
>Hi,
>
>frac works for me:
>
>yaxislabel=r'\sffamily water content $\left( 
>\frac{\textsf{kg}}{\textsf{m}^{\textsf{\small 2}}}\right) $'
>
>ylabel(yaxislabel)
>
>
>And you can also set
>rc('text', usetex=False)
>in your file to enable or disable tex
>
>in my case I did the following:
>
>tex_out=True # False
>if tex_out:
> xaxislabel=r'time ($\sqrt{\textsf{s}}$)'
> yaxislabel=r'\sffamily water content $\left( 
>\frac{\textsf{kg}}{\textsf{m}^{\textsf{\small 2}}}\right) $'
> rc('text', usetex=True)
>else:
> xaxislabel='time (s**0.5)'
> yaxislabel='water content (kg/m2)'
> rc('text', usetex=False)
>
>It's perhaps not the mose elegant way to do, but I'm quite new to 
>python/pylab/matplotlib
>
>
>Wolfgang
>
>John Pye schrieb:
> 
>
>>Hi all
>>
>>I came across this page: http://www.scipy.org/Cookbook/Matplotlib/UsingTex
>>which mentions using LaTeX to generate labels on plots in Matplotlib.
>>
>>What I only discovered recently is that you don't need this 'usetext=1'
>>thing in order to create captions on plots that include subscripts, etc.
>>According to section 2.6.4 of the user's guide, you can just surround
>>your text with $...$ to have it formatted as if it were latex. This is
>>especially important if you're exporting SVG graphics (eg if you want to
>>add more captioning/labelling using inkscape): the 'usetex' approach
>>fails in that case.
>>
>>I wonder if someone with write access to the scipy wiki could maybe
>>update the above page with some comments about the 'mathtext' support in
>>Matplotlib? It might also be worth noting that the mathtext
>>functionality doesn't support the \frac operator.
>>
>>Cheers
>>JP
>>
>> 
>>
>
>
>
>_______________________________________________
>Matplotlib-users mailing list
>Mat...@li...
>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> 
>
From: Wolfgang <wo...@gm...> - 2006年06月16日 09:28:44
Hi,
frac works for me:
yaxislabel=r'\sffamily water content $\left( 
\frac{\textsf{kg}}{\textsf{m}^{\textsf{\small 2}}}\right) $'
ylabel(yaxislabel)
And you can also set
rc('text', usetex=False)
in your file to enable or disable tex
in my case I did the following:
tex_out=True # False
if tex_out:
 xaxislabel=r'time ($\sqrt{\textsf{s}}$)'
 yaxislabel=r'\sffamily water content $\left( 
\frac{\textsf{kg}}{\textsf{m}^{\textsf{\small 2}}}\right) $'
 rc('text', usetex=True)
else:
 xaxislabel='time (s**0.5)'
 yaxislabel='water content (kg/m2)'
 rc('text', usetex=False)
It's perhaps not the mose elegant way to do, but I'm quite new to 
python/pylab/matplotlib
Wolfgang
John Pye schrieb:
> Hi all
> 
> I came across this page: http://www.scipy.org/Cookbook/Matplotlib/UsingTex
> which mentions using LaTeX to generate labels on plots in Matplotlib.
> 
> What I only discovered recently is that you don't need this 'usetext=1'
> thing in order to create captions on plots that include subscripts, etc.
> According to section 2.6.4 of the user's guide, you can just surround
> your text with $...$ to have it formatted as if it were latex. This is
> especially important if you're exporting SVG graphics (eg if you want to
> add more captioning/labelling using inkscape): the 'usetex' approach
> fails in that case.
> 
> I wonder if someone with write access to the scipy wiki could maybe
> update the above page with some comments about the 'mathtext' support in
> Matplotlib? It might also be worth noting that the mathtext
> functionality doesn't support the \frac operator.
> 
> Cheers
> JP
> 
From: John P. <joh...@st...> - 2006年06月16日 07:11:03
Hi all
Is there something missing in pylab that is preventing the flipping of
masked matrices (numerix='numarray'):
from numarray import ma
import pylab
A = ma.array([[1,2],[3,4]],mask=[[1,0],[0,0]])
#print pylab.flipud(A)
A1 = ma.array(pylab.flipud(A.raw_data()),mask=pylab.flipud(A.mask()))
print A1
Is there a better way to do this so that I can just write
pylab.flipud(A)? Does it work ok with numpy?
Cheers
JP
-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney NSW 2052 Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/
From: John P. <joh...@st...> - 2006年06月16日 06:25:45
By the way, I had some success with this, but my approach is really
inefficient. Perhaps someone could suggest how I can improve the following:
import matplotlib.numerix as nx
from numarray import ma
def enumimage(A,colors):
 """
 Create an image from a matrix of enumerated values
 A is a matrix
 colors is a dictionary mapping enumerated values to (r,g,b,a) tuples
 If a value in A is masked, the resulting image will be transparent
 If a value in A is not present in the color map, it will plot black.
 """
 B = nx.zeros((nx.size(A,0),nx.size(A,1),4))
 mask = A.mask()
 for r in range(nx.size(A,0)):
 for c in range(nx.size(A,1)):
 v = A[r,c]
 if mask[r,c]:
 B[r,c,:]=[1,1,1,0]
 else:
 try:
 B[r,c,:]=colors[v]
 except KeyError,e:
 B[r,c,:]=[0,0,0,1]
 return B
 
if __name__=='__main__':
 import pylab
 A = nx.array([[1,2,7],[1,2,2],[1,1,9]])
 print "A =",A
 A1 = ma.array(A,mask=ma.where(A==1,1,0)) 
 print "A1 =",A1
 colors={
 2:(1,0,0,1)
 ,7:(0,1,0,1)
 }
 B = enumimage(A1,colors)
 print "B =",B
 pylab.figure()
 pylab.hold()
 
pylab.imshow(B,interpolation='nearest',extent=0.5+nx.array([0,nx.size(A,0),nx.size(A,1),0]))
 pylab.axes
 pylab.show()
John Pye wrote:
> Hi all
>
> I have some data with enumerated values in an array. Values are like
> 1,2,7,9 spread around in the array. I want to plot those values so that
> I can see the 'regions' in my data, then I want to overlay this with
> some contour lines drawn from other data.
>
> I want to be able to specify the colors for each of the enumerated
> values, as they need to be consistent throughout my work. My array of
> enumerated values is *masked* so that there are areas where I don't want
> to show anything (this would plot as transparent pixels).
>
> Has anyone got suggestions on the best way of doing this? It seems that
> the technique in
> http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values
> might be overkill, right? It also seemed that it had some problems with
> masked arrays.
>
> Cheers
>
> JP
>
> 
-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney NSW 2052 Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/
From: John P. <joh...@st...> - 2006年06月16日 06:22:35
Hi all
I came across this page: http://www.scipy.org/Cookbook/Matplotlib/UsingTex
which mentions using LaTeX to generate labels on plots in Matplotlib.
What I only discovered recently is that you don't need this 'usetext=1'
thing in order to create captions on plots that include subscripts, etc.
According to section 2.6.4 of the user's guide, you can just surround
your text with $...$ to have it formatted as if it were latex. This is
especially important if you're exporting SVG graphics (eg if you want to
add more captioning/labelling using inkscape): the 'usetex' approach
fails in that case.
I wonder if someone with write access to the scipy wiki could maybe
update the above page with some comments about the 'mathtext' support in
Matplotlib? It might also be worth noting that the mathtext
functionality doesn't support the \frac operator.
Cheers
JP
-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney NSW 2052 Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/
From: David H. <dav...@gm...> - 2006年06月16日 04:03:54
Hi,
Numpy has a logspace function, so it may be a bad idea to create a function
in pylab with the same name that does something slightly different.
def logspace(start,stop,num=3D50,endpoint=3DTrue,base=3D10.0):
 """Evenly spaced numbers on a logarithmic scale.
 Computes int(num) evenly spaced exponents from start to stop.
 If endpoint=3DTrue, then last exponent is stop.
 Returns base**exponents.
 """
 y =3D linspace(start,stop,num=3Dnum,endpoint=3Dendpoint)
 return _nx.power(base,y)
David
2006年6月15日, Stefan van der Walt <st...@su...>:
>
> On Tue, Jun 13, 2006 at 06:21:22AM -0500, John Hunter wrote:
> > setting the xscale and yscale to 'log' should work fine, as long as
> > you make sure the xaxis and yaxis do not contain nonpositive limits.
> > For an MxN image, the default limits are 0..N-1 and 0..M-1 and the 0
> > will break the log transform. You can work around this by setting the
> > image "extent"
> >
> > from pylab import figure, show, nx
> > fig =3D figure()
> > ax =3D fig.add_subplot(111)
> > im =3D nx.mlab.rand(500,500)
> > ax.imshow(im, extent=3D(1,501,1,501))
>
> I often want to plot matrices, with the axes labeled according to the
> matrix index. I.e. the top-lefthand element should be (0,0) and the
> bottom-righthand element (rows,columns). Setting the extent does
> work, i.e.
>
> ax.imshow(im,extent=3D(1,columns,rows,1))
>
> If others also use this frequently, it may be useful to have a quick
> way of doing it (or maybe, there already is, and I've missed it).
>
> Regards
> St=E9fan
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: John P. <joh...@st...> - 2006年06月16日 03:39:23
Hi all
I have some data with enumerated values in an array. Values are like
1,2,7,9 spread around in the array. I want to plot those values so that
I can see the 'regions' in my data, then I want to overlay this with
some contour lines drawn from other data.
I want to be able to specify the colors for each of the enumerated
values, as they need to be consistent throughout my work. My array of
enumerated values is *masked* so that there are areas where I don't want
to show anything (this would plot as transparent pixels).
Has anyone got suggestions on the best way of doing this? It seems that
the technique in
http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values
might be overkill, right? It also seemed that it had some problems with
masked arrays.
Cheers
JP
-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney NSW 2052 Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/
From: John H. <jdh...@ac...> - 2006年06月16日 02:16:45
>>>>> "Eric" == Eric Firing <ef...@ha...> writes:
 Eric> One can control the aspect ratio with Axes.set_aspect(), so
 Eric> making a new figure is not really necessary now.
Fernando, if you haven't played with the new aspect handling courtesy
of Mark Bakkar and Eric, you should give it a whirl in your freetime
:-)
As Eric indicates, it "just works" now, under the presence of figure
resizes, etc. Thus some changes in matshow are warranted.
JDH
From: Samuel M. S. <sm...@sa...> - 2006年06月16日 00:20:50
I recently upgraded to 0.87.2 with numpy 0.9.6 on Mac OSX 10.4.6.
The first time I tried to generate a plot with a legend I got this 
error. This same code
did not produce and error the last time I ran it with an earlier 
version.
Is this fixed already in svn?
--> 432 legend(loc = 'lower right')
 433
 434 def PlotClusterRelativeHeadingsAbs(vl, figNum = 1):
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/pylab.py in legend(*args, **kwargs)
 2305
 2306 ret = gca().legend(*args, **kwargs)
-> 2307 draw_if_interactive()
 2308 return ret
 2309 if Axes.legend.__doc__ is not None:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/IPython/genutils.py in wrapper(*args, **kw)
 742 def wrapper(*args,**kw):
 743 wrapper.called = False
--> 744 out = func(*args,**kw)
 745 wrapper.called = True
 746 return out
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/backends/backend_tkagg.py in draw_if_interactive()
 57 figManager = Gcf.get_active()
 58 if figManager is not None:
---> 59 figManager.show()
 60
 61
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/backends/backend_tkagg.py in show(self)
 299 if sys.platform=='win32' : self.window.update()
 300 else:
--> 301 self.canvas.draw()
 302 self._shown = True
 303
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/backends/backend_tkagg.py in draw(self)
 149
 150 def draw(self):
--> 151 FigureCanvasAgg.draw(self)
 152 tkagg.blit(self._tkphoto, self.renderer._renderer, 
colormode=2)
 153 self._master.update_idletasks()
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/backends/backend_agg.py in draw(self)
 396
 397 renderer = self.get_renderer()
--> 398 self.figure.draw(renderer)
 399
 400 def get_renderer(self):
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/figure.py in draw(self, renderer)
 527
 528 # render the axes
--> 529 for a in self.axes: a.draw(renderer)
 530
 531 # render the figure text
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in draw(self, renderer, inframe)
 1467
 1468 if self.legend_ is not None:
-> 1469 self.legend_.draw(renderer)
 1470
 1471
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/legend.py in draw(self, renderer)
 206 if not self.get_visible(): return
 207 renderer.open_group('legend')
--> 208 self._update_positions(renderer)
 209 if self._drawFrame:
 210 if self.shadow:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/legend.py in _update_positions(self, renderer)
 528 for t, tabove in zip(self.texts[1:], self.texts[:-1]):
 529 x,y = t.get_position()
--> 530 l,b,w,h = get_tbounds(tabove)
 531 b -= self.labelsep
 532 h += 2*self.labelsep
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/legend.py in get_tbounds(text)
 521 if not len(self.legendHandles) and not len 
(self.texts): return
 522 def get_tbounds(text): #get text bounds in axes coords
--> 523 bbox = text.get_window_extent(renderer)
 524 bboxa = inverse_transform_bbox(self._transform, 
bbox)
 525 return bboxa.get_bounds()
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/text.py in get_window_extent(self, renderer)
 461 bbox, tmp = self._get_layout_super 
(self._renderer, m)
 462 return bbox
--> 463 bbox, info = self._get_layout(self._renderer)
 464 return bbox
 465
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/text.py in _get_layout(self, renderer)
 184 heightt += 3 # 3 pixel pad
 185 for line in lines:
--> 186 w,h = renderer.get_text_width_height(
 187 line, self._fontproperties, 
ismath=self.is_math_text())
 188
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/backends/backend_agg.py in get_text_width_height 
(self, s, prop, ismath, rgb)
 247 # todo: handle props
 248 size = prop.get_size_in_points()
--> 249 Z = self.texmanager.get_rgba(s, size, self.dpi.get 
(), rgb)
 250 m,n,tmp = Z.shape
 251 return n,m
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/texmanager.py in get_rgba(self, tex, fontsize, 
dpi, rgb)
 378 if Z is None:
 379 # force=True to skip cacheing while debugging
--> 380 pngfile = self.make_png(tex, fontsize, dpi, 
force=False)
 381 X = readpng(pngfile)
 382 vers = self.get_dvipng_version()
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/texmanager.py in make_png(self, tex, fontsize, 
dpi, force)
 207 if debug: force = True
 208
--> 209 dvifile = self.make_dvi(tex, fontsize)
 210 prefix = self.get_prefix(tex, fontsize, dpi)
 211 pngfile = os.path.join(self.texcache, '%s.png'% prefix)
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/texmanager.py in make_dvi(self, tex, fontsize, 
force)
 190 stdout=PIPE, close_fds=True)
 191 exit_status = process.wait()
--> 192 if exit_status: raise RuntimeError('LaTeX was not 
able to process \
 193 the flowing string:\n%s\nHere is the full report generated 
by LaTeX: \
 194 \n\n'% tex + process.stdout.read())
RuntimeError: LaTeX was not able to process the flowing string:
(V0_msl,V1_msl)
Here is the full report generated by LaTeX:
This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5)
entering extended mode
(/Users/smithsm/.matplotlib/tex.cache/ 
8a40b78bc1a9a623e6e789f1fb6f807e.tex
LaTeX2e <2003年12月01日>
Babel <v3.8d> and hyphenation patterns for american, british, french, 
german, n
german, dutch, italian, norsk, portuges, spanish, swedish, 
nohyphenation, loade
d.
(/usr/local/teTeX/share/texmf.tetex/tex/latex/base/article.cls
Document Class: article 2004年02月16日 v1.4f Standard LaTeX document class
(/usr/local/teTeX/share/texmf.tetex/tex/latex/base/size10.clo))
(/usr/local/teTeX/share/texmf.tetex/tex/latex/type1cm/type1cm.sty)
(/usr/local/teTeX/share/texmf.tetex/tex/latex/psnfss/helvet.sty
(/usr/local/teTeX/share/texmf.tetex/tex/latex/graphics/keyval.sty))
(/usr/local/teTeX/share/texmf.tetex/tex/latex/psnfss/courier.sty)
(/usr/local/teTeX/share/texmf.tetex/tex/latex/base/textcomp.sty
(/usr/local/teTeX/share/texmf.tetex/tex/latex/base/ts1enc.def))
(/usr/local/teTeX/share/texmf.tetex/tex/latex/geometry/geometry.sty
(/usr/local/teTeX/share/texmf.tetex/tex/latex/geometry/geometry.cfg)
Package geometry Warning: Over-specification in `h'-direction.
 `width' (5058.9pt) is ignored.
Package geometry Warning: Over-specification in `v'-direction.
 `height' (5058.9pt) is ignored.
)
No file 8a40b78bc1a9a623e6e789f1fb6f807e.aux.
(/usr/local/teTeX/share/texmf.tetex/tex/latex/base/ts1cmr.fd)
(/usr/local/teTeX/share/texmf.tetex/tex/latex/psnfss/ot1pnc.fd)
(/usr/local/teTeX/share/texmf.tetex/tex/latex/psnfss/ot1phv.fd)
! Missing $ inserted.
<inserted text>
 $
l.10 ...tsize{10.000000}{12.500000}{\sffamily (V0_
 msl,V1_msl)}
! Extra }, or forgotten $.
l.10 ...000}{12.500000}{\sffamily (V0_msl,V1_msl)}
! Missing $ inserted.
<inserted text>
 $
l.11 \end{document}
[1] (./8a40b78bc1a9a623e6e789f1fb6f807e.aux) )
(\end occurred inside a group at level 1)
### simple group (level 1) entered at line 10 ({)
### bottom level
(see the transcript file for additional information)
Output written on 8a40b78bc1a9a623e6e789f1fb6f807e.dvi (1 page, 380 
bytes).
Transcript written on 8a40b78bc1a9a623e6e789f1fb6f807e.log.
**********************************************************************
Samuel M. Smith Ph.D.
2966 Fort Hill Road
Eagle Mountain, Utah 84043
801-768-2768 voice
801-768-2769 fax
**********************************************************************
"The greatest source of failure and unhappiness in the world is
giving up what we want most for what we want at the moment"
**********************************************************************

Showing 12 results of 12

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