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


Showing 22 results of 22

From: Carlos G. <car...@gm...> - 2010年09月18日 18:57:14
Many thanks Ben!
I went and removed all fonts but regular helvetica and vera, also I
removed all but the .png files under images, and now my mpl-data is
about 250 kb.
cheers
Carlos
On Thu, Sep 16, 2010 at 21:39, Benjamin Root <ben...@ou...> wrote:
> On Thu, Sep 16, 2010 at 5:33 PM, Carlos Grohmann <car...@gm...>
> wrote:
>>
>> Hello all,
>>
>> Is it OK to remove the fonts I don't use? (I use only sans-serif) By
>> Ok I mean not only from the practical poin tof view (that is, will the
>> app run?) but also from the _legal_ point of view (am I obliged to
>> distribute all those fonts?)
>>
>
> Carlos,
>
> Just to make it very clear, matplotlib is open sourced. You are free to
> modify the package to your heart's content, however you see fit. Matplotlib
> only asks that you keep the copyright notice with the distributed software
> (in particular, the matplotlib/license/LICENSE file applies here, as well as
> others.)
>
> With regards to fonts, refer to the matplotlib/license/LICENSE_STIX file.
> My understanding of that license (though, IANAL), is that you don't have to
> worry about anything above and beyond just simply including the license file
> unless you are eliminating individual glyphs from a font (or adding
> glyphs). However, I don't see any reason why you can't constrain yourself
> to a particular font. Note that you are not allowed to sell any particular
> font in the package, though you are allowed to charge a distribution fee for
> the "font software".
>
> Generally speaking, my rule of thumb is that if you are distributing
> open-source software in the same spirit you have received it, you are
> satisfying the spirit of the licenses. The only thing remaining is whether
> the source code has to accompany the software or not. The core part of
> matplotlib is BSD licensed (or similar) and does not require that (although
> it is encouraged!).
>
> Important! Note that the basemap package is GPL-licensed, and is required to
> have its source code accompany its software. However, unless your program
> *depends* on basemap for it to function, the source code to your program is
> not required to be GPL-ed.
>
> And, as always, I am not a lawyer. I am merely conveying my understanding
> and experience with software licensing. Anyone else is free to add to
> and/or correct what I have said here.
>
> I hope this helps!
> Ben Root
>
-- 
Prof. Carlos Henrique Grohmann - Geologist D.Sc.
Institute of Geosciences - Univ. of São Paulo, Brazil
http://www.igc.usp.br/pessoais/guano
http://lattes.cnpq.br/5846052449613692
Linux User #89721
________________
Can’t stop the signal.
From: musik <xi....@gm...> - 2010年09月18日 18:31:14
That works perfectly. Thank you all so much! 
Gökhan SEVER-2 wrote:
> 
> On Fri, Sep 17, 2010 at 1:13 PM, musik <xi....@gm...> wrote:
> 
>>
>> Is there a way to set the legend font color? I am plotting multiple sets
>> of
>> data using different colors. I basically want to set each legend font
>> color
>> the same as the corresponding data line color. Here is an example.
>>
>> x = arange(0,10,0.1)
>> y1 = sin(x)
>> y2 = cos(x)
>>
>> plot(x,y1,'r-',x,y2,'b--')
>>
>> I want the legend font for y1 to be in red and the legend font for y2 to
>> be
>> in blue.
>>
>> Can anybody help? Thanks.
>>
> 
> I initially read like Ted did :) Here is a simple demonstration of Ben's
> explanation:
> 
> x = np.arange(0,10,0.1)
> y1 = np.sin(x)
> y2 = np.cos(x)
> fig = plt.figure()
> ax = fig.add_subplot(111)
> p1, = ax.plot(x, y1, label="y1")
> p2, = ax.plot(x, y2, label="y2")
> leg = ax.legend()
> text1, text2 = leg.get_texts()
> # this part can be turned into a loop depends on the number of text
> objects
> text1.set_color(p1.get_color())
> text2.set_color(p2.get_color())
> plt.show()
> 
> 
> -- 
> Gökhan
> 
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/legend-font-color-tp29741260p29747823.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2010年09月18日 18:29:43
On Fri, Sep 17, 2010 at 11:33 PM, Jeremy Conlin <jlc...@gm...> wrote:
> On Fri, Sep 17, 2010 at 12:44 AM, Scott Sinclair
> <sco...@gm...> wrote:
> > On 16 September 2010 22:52, Jeremy Conlin <jlc...@gm...> wrote:
> >> I have a colorbar which has some ticks, but I would like to add my own
> >> ticks without replacing any of the existing ones. In addition, I
> >> would like to give the ticks a different labels like "min" and "max".
> >> Can someone show how this might be done?
> >
> >
> http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
> > should give you some ideas to get started.
>
> Thanks for pointing me to that demo, it's a good one. However, I want
> the ticks that are generated automatically, in addition to the extra
> ones I add. The demo seems to show how I can define my own only.
>
> Jeremy
>
>
While I haven't tried this, so there might be a few extra things to do to
make this work... You could first call
ticks = cbar.ax.get_yticks()
tickStrs = [label.get_text() for label in cbar.ax.get_yticklabels()]
to get the list of tick locations and the strings.
Then, insert any additional ticks at whatever locations you want in 'ticks'.
Next, insert the desired strings at the same locations in 'tickStrs'.
Then, update the tick locations and strings in cbar:
cbar.set_ticks(ticks, update_ticks=False)
cbar.set_ticklabels(tickStrs, update_ticks=True)
The use of update_ticks=False is to defer the actual processing of the tick
data until later. This is to avoid conflicts with the differing lengths of
tick locations and tick labels. The update would then occur at the end of
set_ticklabels().
Note, I have not tested this, so there is no guarantee that this would
work. Good luck!
Ben Root
From: Benjamin R. <ben...@ou...> - 2010年09月18日 18:03:38
On Sat, Sep 18, 2010 at 10:39 AM, Gökhan Sever <gok...@gm...>wrote:
> On Fri, Sep 17, 2010 at 8:59 PM, Benjamin Root <ben...@ou...> wrote:
>>
>> Not a bug, but a "feature". In step(), the 'linestyle' kwarg gets
>> over-ridden with a value of 'steps-' + kwargs['where'].
>>
>> Ben Root
>>
>
> Hard to interpret that way at the first look. This does what I want:
>
> plt.plot(range(10), 'g--', drawstyle='steps-mid')
>
>
I'll admit that I am not very familiar with how these step plots are done.
Maybe it should be the 'drawstyle' kwarg that should be over-riden, not
'linestyle'?
Ben Root
From: Gökhan S. <gok...@gm...> - 2010年09月18日 15:40:05
On Fri, Sep 17, 2010 at 8:59 PM, Benjamin Root <ben...@ou...> wrote:
>
> Not a bug, but a "feature". In step(), the 'linestyle' kwarg gets
> over-ridden with a value of 'steps-' + kwargs['where'].
>
> Ben Root
>
Hard to interpret that way at the first look. This does what I want:
plt.plot(range(10), 'g--', drawstyle='steps-mid')
-- 
Gökhan
From: Joey R. <jo...@ca...> - 2010年09月18日 14:25:18
Hi Mario,
(Sorry for the reply to a reply, but I was not on the list when the original message was posted)
This may not be useful for Basemap, but I did this with the matplotlib.projections.geo HammerAxes projection. I got it to work by subclassing that and modifying the _get_affine_transform() to negate the x-axis scale. I also seem to have had to fiddle with _set_lim_and_transforms() to account for this, though I don't remember the details.
In any case, I don't know how Basemap works and whether this is helpful. Maybe as inspiration... The code is below if it helps.
joey
On Sep 18, 2010, at 6:02 AM, Jeff Whitaker wrote:
> On 9/16/10 12:38 PM, Mario Juric wrote:
>> Hi,
>> 	I'm looking at Basemap as a backend for plotting maps of the sky in
>> different projections, and so far it seems like a really good match!
>> Excellent work!
>> 
>> 	The only problem that I don't know how to solve is that in astronomy
>> the longitude on maps typically increases from right to left (we're
>> looking at the celestial sphere from the "inside"). Is there any way (or
>> a trick) to make Basemap do this?
>> 
>> Regards,
class AstroHammerAxes(HammerAxes):
 """Astronomical hammer projection.
 This is just a Hammer projection with the longitude axis
 reversed left-right.
 """
 name='astrohammer'
 def _get_affine_transform(self):
 """get affine transform
 This is cribbed from GeoAxes, but negates the xscale
 to put positive longitude to the left. Not sure this
 is actually robust.
 """
 transform=self._get_core_transform(1)
 xscale,_=transform.transform_point((pi,0))
 _,yscale=transform.transform_point((0,pi/2.0))
 return Affine2D()\
 .scale(-0.5/xscale, 0.5/yscale)\
 .translate(0.5,0.5)
 def _set_lim_and_transforms(self):
 HammerAxes._set_lim_and_transforms(self)
 yaxis_stretch = Affine2D().scale(pi * 2.0, 1.0).translate(pi, 0.0)
 yaxis_space = Affine2D().scale(1.0, 1.1)
 yaxis_text_base = \
 yaxis_stretch + \
 self.transProjection + \
 (yaxis_space + \
 self.transAffine + \
 self.transAxes)
 self._yaxis_text1_transform = \
 yaxis_text_base + \
 Affine2D().translate(-8.0, 0.0)
 self._yaxis_text2_transform = \
 yaxis_text_base + \
 Affine2D().translate(8.0, 0.0)
# register the projection on import
register_projection(AstroHammerAxes)
From: Jeff W. <js...@fa...> - 2010年09月18日 13:15:45
 On 9/16/10 12:38 PM, Mario Juric wrote:
> Hi,
> 	I'm looking at Basemap as a backend for plotting maps of the sky in
> different projections, and so far it seems like a really good match!
> Excellent work!
>
> 	The only problem that I don't know how to solve is that in astronomy
> the longitude on maps typically increases from right to left (we're
> looking at the celestial sphere from the "inside"). Is there any way (or
> a trick) to make Basemap do this?
>
> Regards,
Mario: Are you asking whether the basemap coordinate system can be 
reversed, or just the longitude labelling? If it's the former, the 
answer is no. If you just want the labels reversed, you can pass the 
drawmeridians method a custom formatting function with the 'fmt' keyword.
-Jeff
From: Jeremy C. <jlc...@gm...> - 2010年09月18日 04:33:11
On Fri, Sep 17, 2010 at 12:44 AM, Scott Sinclair
<sco...@gm...> wrote:
> On 16 September 2010 22:52, Jeremy Conlin <jlc...@gm...> wrote:
>> I have a colorbar which has some ticks, but I would like to add my own
>> ticks without replacing any of the existing ones. In addition, I
>> would like to give the ticks a different labels like "min" and "max".
>> Can someone show how this might be done?
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
> should give you some ideas to get started.
Thanks for pointing me to that demo, it's a good one. However, I want
the ticks that are generated automatically, in addition to the extra
ones I add. The demo seems to show how I can define my own only.
Jeremy
From: Jason G. <jas...@cr...> - 2010年09月18日 03:58:17
On 9/17/10 9:08 PM, Fernando Perez wrote:
> Hi Luke,
>
> On Fri, Sep 17, 2010 at 5:49 PM, Dale Lukas Peterson
> <haz...@gm...> wrote:
>>
>> I'm not sure I understand how I would make use of my function then.
>> My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the
>> level surfaces (not contour lines) calculated. I guess I could treat
>> z as a parameter, then plot the zero level contour lines of my function for
>> a discrete number of z values, but then I would need to adjust the
>> height that each countour line is plotted at when I do the 3-d plot.
>> This still would only give bunch of vertically stacked contour
>> lines, rather than a nice smooth 3-d surface.
>>
>> If I'm misunderstanding what you meant, perhaps you could point me
>> to an example of something that makes a level surface of a function
>> of 3 (not 2) variables?
>
> You're looking for an isosurface; as far as I know matplotlib does not
> have isosurface modules, only 2-d contours embedded in 3d (such as
> those illustrated in
> http://matplotlib.sourceforge.net/examples/mplot3d/contourf3d_demo.html).
>
> VTK does have powerful isosurface capabilities, nicely exposed by mayavi:
>
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#contour3d
Sage will also do this sort of thing, though it's not as powerful as 
VTK/Mayavi in this functionality:
http://www.sagemath.org/doc/reference/sage/plot/plot3d/implicit_plot3d.html
Here are lots of sheets on sagenb.org that use implicit_plot3d somewhere:
http://sagenb.org/pub/?typ=pub&search=implicit_plot3d
Thanks,
Jason
From: Fernando P. <fpe...@gm...> - 2010年09月18日 02:09:06
Hi Luke,
On Fri, Sep 17, 2010 at 5:49 PM, Dale Lukas Peterson
<haz...@gm...> wrote:
>
> I'm not sure I understand how I would make use of my function then.
> My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the
> level surfaces (not contour lines) calculated. I guess I could treat
> z as a parameter, then plot the zero level contour lines of my function for
> a discrete number of z values, but then I would need to adjust the
> height that each countour line is plotted at when I do the 3-d plot.
> This still would only give bunch of vertically stacked contour
> lines, rather than a nice smooth 3-d surface.
>
> If I'm misunderstanding what you meant, perhaps you could point me
> to an example of something that makes a level surface of a function
> of 3 (not 2) variables?
You're looking for an isosurface; as far as I know matplotlib does not
have isosurface modules, only 2-d contours embedded in 3d (such as
those illustrated in
http://matplotlib.sourceforge.net/examples/mplot3d/contourf3d_demo.html).
VTK does have powerful isosurface capabilities, nicely exposed by mayavi:
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#contour3d
If the mlab helper isn't sufficient for you, you can create directly
VTK isosurfaces, the heart example is a good point to start learning:
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/example_heart.html
Regards,
f
From: Benjamin R. <ben...@ou...> - 2010年09月18日 02:00:16
On Fri, Sep 17, 2010 at 8:43 PM, Gökhan Sever <gok...@gm...> wrote:
> On Fri, Sep 17, 2010 at 3:34 PM, Gökhan Sever <gok...@gm...>wrote:
>
>> Hello,
>>
>> Can someone confirm me if this creates a dashed line for a simple step
>> plot?
>>
>> # this is fine
>> plt.plot(range(10), "g--")
>>
>> # plots solid line!
>> plt.step(range(10), "g--")
>>
>> Thanks,
>>
>> --
>> Gökhan
>>
>
> My version is v8624. Looks like a bug to me.
>
Not a bug, but a "feature". In step(), the 'linestyle' kwarg gets
over-ridden with a value of 'steps-' + kwargs['where'].
Ben Root
From: Benjamin R. <ben...@ou...> - 2010年09月18日 01:52:06
On Fri, Sep 17, 2010 at 4:37 PM, Jeremy Lewi <jl...@in...> wrote:
> HI,
>
>
>
> Is there a way to get the size of the bounding box for the axes which
> includes the axes labels and tick marks? It looks like
> Axes.get_position/set_position refers to the inner position (i.e the actual
> plot area).
>
>
>
>
>
> In matlab (http://www.mathworks.com/help/techdoc/ref/axes_props.html) this
> was the outer and inner position of an axes. I would like to get the outer
> position (i.e the yellow box in
> http://www.mathworks.com/help/techdoc/ref/axes_props.html)
>
>
>
> Thanks
>
> Jeremy
>
>
>
> Jeremy Lewi
>
> Engineering Scientist
>
> The Intellisis Corporation
>
> jl...@in...
>
>
>
>
Jeremy,
Yes, get/set_position refers to the position of the plot area within a
particular axes area in a figure. I am not exactly aware of how one
determines its outer boundary box, because there really isn't an outer box.
Everything within an axes area is plotted within coordinates of 0 to 1. The
plot box is set typically at 0.125 to 0.9. Axes labels are then draw as an
offset relative to the plot area. This can cause the axes labels and figure
titles to overlap each other in neighboring subplots if they get too big.
Tony Yu did make some code to help deal with display issues surrounding the
lack of a constrained outer box. See this link for some discussion of it
and the code. Maybe it can help you with whatever you need.
http://permalink.gmane.org/gmane.comp.python.matplotlib.general/24652
I hope that helps!
Ben Root
From: Gökhan S. <gok...@gm...> - 2010年09月18日 01:43:42
On Fri, Sep 17, 2010 at 3:34 PM, Gökhan Sever <gok...@gm...> wrote:
> Hello,
>
> Can someone confirm me if this creates a dashed line for a simple step
> plot?
>
> # this is fine
> plt.plot(range(10), "g--")
>
> # plots solid line!
> plt.step(range(10), "g--")
>
> Thanks,
>
> --
> Gökhan
>
My version is v8624. Looks like a bug to me.
From: Gökhan S. <gok...@gm...> - 2010年09月18日 01:41:37
On Fri, Sep 17, 2010 at 1:13 PM, musik <xi....@gm...> wrote:
>
> Is there a way to set the legend font color? I am plotting multiple sets of
> data using different colors. I basically want to set each legend font color
> the same as the corresponding data line color. Here is an example.
>
> x = arange(0,10,0.1)
> y1 = sin(x)
> y2 = cos(x)
>
> plot(x,y1,'r-',x,y2,'b--')
>
> I want the legend font for y1 to be in red and the legend font for y2 to be
> in blue.
>
> Can anybody help? Thanks.
>
I initially read like Ted did :) Here is a simple demonstration of Ben's
explanation:
x = np.arange(0,10,0.1)
y1 = np.sin(x)
y2 = np.cos(x)
fig = plt.figure()
ax = fig.add_subplot(111)
p1, = ax.plot(x, y1, label="y1")
p2, = ax.plot(x, y2, label="y2")
leg = ax.legend()
text1, text2 = leg.get_texts()
# this part can be turned into a loop depends on the number of text objects
text1.set_color(p1.get_color())
text2.set_color(p2.get_color())
plt.show()
-- 
Gökhan
From: Benjamin R. <ben...@ou...> - 2010年09月18日 01:28:26
On Fri, Sep 17, 2010 at 4:57 PM, John Hutchinson <jmh...@gm...> wrote:
> Hi:
>
> I am trying to make a 1row by 3 column plot with subplot, and I want
> the first plot (subplot(131)) to have equal aspect ratio, but the rest
> can auto scale.
>
> My code results in an empty plot for the 1st column subplot whenever I
> try to use the set_aspect('equal')
>
> Any ideas?
>
> Thanks
> John
>
>
> figure(1)
> hold(True)
> subplot(131)
> plot(RX,RY)
> title('Geometry')
> xlabel('um')
> ylabel('um')
> scatter(AX,AY,c='green',marker='s')
> plot([AX,0],[AY,0],linewidth=3,c='green')
> scatter(BX,BY,c='purple',marker='s')
> plot([0,BX],[0,BY],linewidth=3,c='purple')
> scatter(DX,DY,c='red',marker='o')
> axes().set_aspect('equal')
> hold(False)
> subplot(132)
> scatter(e1.real,gi,marker='s')
> title('E1 by tooth')
> subplot(133)
> scatter(e2.real,gi,marker='+')
> title('E2 by tooth')
> show()
>
>
This is most likely because of the call to axes(). I can't remember for
sure, but it might be automatically clearing out the axes. Replace axes()
with subplot(131):
subplot(131).set_aspect('equal')
The subplot(131) call should recognize that that particular axes has already
been made and just simply retrieves it without modifying anything.
I hope this helps!
Ben Root
From: Benjamin R. <ben...@ou...> - 2010年09月18日 01:23:26
On Fri, Sep 17, 2010 at 8:05 PM, Forest Yang <yzi...@gm...> wrote:
> Hi
>
> I have a function z(x, y) on a regular grid. But some of the value
> z are not defined on (x,y). I want to plot the contour or contourf of
> z on (x,y) but exclude specific (x,y) points.
> How can I do it ? Right now I just draw small colored square
> (rectangular) around defined (x,y) the color is not smooth since no
> interpolation like contour or contourf.
>
> Thanks.
>
> Forest.
>
>
Forest,
There are a few ways to do this. If you have a recent enough version of
matplotlib, you can use masked arrays, and the contourf will just ignore
those data points. One could also use NaNs and make sure that the clim (the
limits on z that you wish to display a color for) is defined.
To make a masked array is easy. Imagine you wish to exclude any value less
than zero (assume z is defined):
import numpy.ma as ma
z_masked = ma.masked_array(z, mask=(z < 0.))
And then just use the masked array in your contourf as you would the
regular numpy array.
I hope that helps!
Ben Root
From: Ted K. <ted...@gm...> - 2010年09月18日 01:21:37
I misunderstood your question, musik. My apologies.
Ted
On 18 September 2010 02:15, Benjamin Root <ben...@ou...> wrote:
> On Fri, Sep 17, 2010 at 1:13 PM, musik <xi....@gm...> wrote:
>
>>
>> Is there a way to set the legend font color? I am plotting multiple sets
>> of
>> data using different colors. I basically want to set each legend font
>> color
>> the same as the corresponding data line color. Here is an example.
>>
>> x = arange(0,10,0.1)
>> y1 = sin(x)
>> y2 = cos(x)
>>
>> plot(x,y1,'r-',x,y2,'b--')
>>
>> I want the legend font for y1 to be in red and the legend font for y2 to
>> be
>> in blue.
>>
>> Can anybody help? Thanks.
>>
>>
>>
> musik,
>
> I am not aware of any easy way to control the font properties for each
> individual item in a legend box. I would suppose that it would be possible
> to obtain the list of Text objects from the legend object (*after* creating
> the legend object), and then modify their color properties based on the
> string that it contains. Note that I have never personally tried this.
>
> As far as I can tell, the text for the legend elements are black by
> default. Note that you can set the font properties for all Text objects in
> a legend when creating the legend with the 'prop' kwarg.
>
> I hope this helps,
> Ben Root
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Benjamin R. <ben...@ou...> - 2010年09月18日 01:15:51
On Fri, Sep 17, 2010 at 1:13 PM, musik <xi....@gm...> wrote:
>
> Is there a way to set the legend font color? I am plotting multiple sets of
> data using different colors. I basically want to set each legend font color
> the same as the corresponding data line color. Here is an example.
>
> x = arange(0,10,0.1)
> y1 = sin(x)
> y2 = cos(x)
>
> plot(x,y1,'r-',x,y2,'b--')
>
> I want the legend font for y1 to be in red and the legend font for y2 to be
> in blue.
>
> Can anybody help? Thanks.
>
>
>
musik,
I am not aware of any easy way to control the font properties for each
individual item in a legend box. I would suppose that it would be possible
to obtain the list of Text objects from the legend object (*after* creating
the legend object), and then modify their color properties based on the
string that it contains. Note that I have never personally tried this.
As far as I can tell, the text for the legend elements are black by
default. Note that you can set the font properties for all Text objects in
a legend when creating the legend with the 'prop' kwarg.
I hope this helps,
Ben Root
From: Forest Y. <yzi...@gm...> - 2010年09月18日 01:05:57
Hi
 I have a function z(x, y) on a regular grid. But some of the value
z are not defined on (x,y). I want to plot the contour or contourf of
z on (x,y) but exclude specific (x,y) points.
How can I do it ? Right now I just draw small colored square
(rectangular) around defined (x,y) the color is not smooth since no
interpolation like contour or contourf.
Thanks.
Forest.
From: Joey R. <jo...@ca...> - 2010年09月18日 00:57:27
Hello. First, let me apologize if this has been covered---I tried to search the mailing list archives but was unable to get that to work (even queries that should have returned many hits were returning nothing). 
When I plot with the MacOSX backend using a serif font, the negative signs on the axis labels show up as the "missing glyph" open squares rather than minus signs.
Things that work around the problem: 
- disabling the unicode minus sign via axes.unicode_minus: False in the matplotlibrc file (though this obviously gives a hyphen instead of a true minus sign)
- switching to a sans-serif font
- switching to TkAgg or wxAgg backends
- using the text.usetex option
Things that don't work:
- switching to a different serif font (at least among Times, Times New Roman, and Bitstream Vera Serif)
I am using matplotlib 1.0 installed from the dmg file for Python 2.6 on OSX 10.6. I'm using Python 2.6.6 installed from the python.org binary distribution.
For now, I can work around using a sans-serif font or different backend instead, but I'd really like to use a serif font with the MacOSX backend. Please let me know if you need any other information. Your assistance would be most appreciated, thank you.
joey
From: Dale L. P. <haz...@gm...> - 2010年09月18日 00:49:19
David,
 I'm not sure I understand how I would make use of my function then.
 My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the
 level surfaces (not contour lines) calculated. I guess I could treat
 z as a parameter, then plot the zero level contour lines of my function for
 a discrete number of z values, but then I would need to adjust the
 height that each countour line is plotted at when I do the 3-d plot.
 This still would only give bunch of vertically stacked contour
 lines, rather than a nice smooth 3-d surface.
 If I'm misunderstanding what you meant, perhaps you could point me
 to an example of something that makes a level surface of a function
 of 3 (not 2) variables?
Thanks,
~Luke
On Thu, Sep 16, 2010 at 05:28:47AM +0200, Daπid wrote:
> I think you can make it with pyplot.contourf() and the argument V
> 
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contour
> 
> "contour(Z,V)
> contour(X,Y,Z,V)
> 
> draw contour lines at the values specified in sequence V"
> 
> On Wed, Sep 15, 2010 at 9:02 PM, Luke <haz...@gm...> wrote:
> > I have a function of three variables and am interested in plotting the zero
> > level surface:
> > f(x,y,z) = 0
> > Is there a simple way to plot this level surface in 3-D without having to
> > resort to meshing up x and y, and solving for the z that satisfies the
> > equation? I can do this, but it gets messy because there are anywhere from
> > 0 to 2 solutions to the equation for each point in the x-y plane.
> > The mplot3d examples all seem to calculate the z-data simply from simple
> > functions of x and y.
> > Thanks,
> > ~Luke
> > ------------------------------------------------------------------------------
> > Start uncovering the many advantages of virtual appliances
> > and start using them to simplify application deployment and
> > accelerate your shift to cloud computing.
> > http://p.sf.net/sfu/novell-sfdev2dev
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
From: Ted K. <ted...@gm...> - 2010年09月18日 00:48:47
It does this automatically.
ted
On 17 September 2010 19:13, musik <xi....@gm...> wrote:
>
> Is there a way to set the legend font color? I am plotting multiple sets of
> data using different colors. I basically want to set each legend font color
> the same as the corresponding data line color. Here is an example.
>
> x = arange(0,10,0.1)
> y1 = sin(x)
> y2 = cos(x)
>
> plot(x,y1,'r-',x,y2,'b--')
>
> I want the legend font for y1 to be in red and the legend font for y2 to be
> in blue.
>
> Can anybody help? Thanks.
>
>
>
> --
> View this message in context:
> http://old.nabble.com/legend-font-color-tp29741260p29741260.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

Showing 22 results of 22

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