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




Showing 8 results of 8

From: Benyang T. <ben...@jp...> - 2005年05月27日 21:09:46
I have a quick hack of basemap to allow it to draw a great circle passing the 
map borders. It should work for the cylinder project (i.e., no projection) 
and a map with longitude -180 to 180.
Instruction:
- Edit the file:
PythonInstallDirectory/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py
- Insert the following line
 x,y = fixlon(x,y)
before this line 
 self.plot(x,y,**kwargs)
- Add the following to the top of the file:
import Numeric as Num
import MA
def fixlon(lon,lat):
 if type(lon) == type([1,]) or type(lon) == type((1,)):
 lon0 = Num.array(lon)
 lat0 = Num.array(lat)
 else:
 lon0 = lon
 lat0 = lat
# 
 n = len(lon0)
 temp1 = lon0[1:] - lon0[:-1]
 temp2 = temp1>0
 np = Num.sum(temp2)
#
 isIncrease = None
 if np<=2:
 isIncrease = 1
 elif n-np<=2:
 isIncrease = 0
 else:
 print 'n, np = ', n, np
 return
#
 if not isIncrease:
 temp2 = Num.logical_not(temp2)
 temp3 = Num.nonzero(temp2)
 i0 = Num.argmax( Num.take(Num.fabs(temp1), temp3) )
 i = temp3[i0]
 print 'n,i=', n, i
# 
 lon1 = 
MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode())
 lat1 = 
MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode())
 lon1[:i+1] = lon0[:i+1]
 lat1[:i+1] = lat0[:i+1]
 lon1[i+2:] = lon0[i+1:]
 lat1[i+2:] = lat0[i+1:]
 lon1.mask()[i+1] = 1
 lat1.mask()[i+1] = 1
#
 return lon1, lat1
From: John H. <jdh...@ac...> - 2005年05月27日 17:32:31
>>>>> "Meesters," == Meesters, Christian <mee...@un...> writes:
 Meesters> Hi, It's me again ... I still do not find my way out of
 Meesters> the problem on how I can apply a format to the
 Meesters> numbering of an axis. I am using the WXAgg backend and
 Meesters> this is my code:
To apply a "default font" for the entire figure, you can use the rc
params -- see http://matplotlib.sf.net/.matplotlibrc, especially the
font.*, axes.* and tick.* settings
 from matplotlib import rc
 from pylab import figure, show
 rc('font', weight='bold', style='italics')
 rc('axes', labelsize=25)
 rc('tick', labelsize=14)
 fig = figure()
 ax = fig.add_subplot(111)
 ax.plot(range(10))
 ax.set_xlabel('hi')
 ax.set_ylabel('bye')
 ax.set_title('easy as 1-2-3')
 show()
You can also customize the default tick labels sizes individually. I
already noted that for the xlabel, ylabel and title you can use
kwargs, eg
 ax.set_xlabel('hi', fontsize='smaller')
and so on.
For the tick labels, you will need to get a list of the tick label
Text instances you want to customize
 labels = ax.get_xticklabels()
You can call any of the text setter methods on these labels, which are
detailed here
http://matplotlib.sourceforge.net/matplotlib.text.html#Text
For example, you can set the fontsize or fontproperty with
for label in labels:
 label.set_fontsize(mysize)
for label in labels:
 label.set_fontproperties(fp)
A lot of the methods like set_fontsize are historical artifacts from
before we had font properties, and they just forward the call to the
property
If you want finer grained control over the major and minor ticks, or
different customizations for the top and bottom ticks (on the xaxis
the top ticks are normally off but you can turn them on) you can do
that too, but it is a little more work
 # ditto for get_minor_ticks
 ticks = ax.xaxis.get_major_ticks()
 majLabelsLower = [tick.label1 for tick in ticks]
 majLabelsUpper = [tick.label2 for tick in ticks]
and then call the setter methods on these as above.
Hope this helps,
JDH
From: Ken M. <mc...@ii...> - 2005年05月27日 17:29:02
Meesters, Christian wrote:
> It's me again ... I still do not find my way out of the problem on how I can
 > apply a format to the numbering of an axis. I am using the WXAgg backend and
 > this is my code:
It sounds like you tring to change the formatting of the tick labels of the 
axes. I believe that the RC parameter `tick.labelsize' will do the trick if 
this is all you need. There are doubtless a slew of other tick-related options.
If you're trying to do something more complicated, like setup complicated font 
properties for the labels, the following approach might work.
def fontify_ticks(axes, fp):
	xticks = axes.xaxis.get_major_ticks() + axes.xaxis.get_minor_ticks()
	yticks = axes.yaxis.get_major_ticks() + axes.yaxis.get_minor_ticks()
	for t in xticks + yticks:
		t.label1.set_fontproperties(fp) # outer/upper tick label
		t.label2.set_fontproperties(fp) # inner/lower tick label
I hope this helps.
Ken
From: Meesters, C. <mee...@un...> - 2005年05月27日 17:09:17
Attachments: test.jpg
Hi,=20
It's me again ... I still do not find my way out of the problem on how I =
can apply a format to the numbering of an axis. I am using the WXAgg =
backend and this is my code:
font =3D FontProperties()
self.font =3D font.copy()
self.font.set_size('x-small')
self.font.set_family('serif')
self.font.set_style('normal')
self.font.set_variant('normal')
self.font.set_weight('light')
<snip>and then a function plot_data:
def plot_data(self):
<snip>
			a =3D self.fig.add_subplot(111)
			a.grid(self.g)
	=09
		for x,y in zip(self.active_datasets,linestyles):
			if len(self.datasets)=3D=3D1: a.set_title('Spatial Distribution of =
%s' % x.attributes['name'], fontproperties=3Dself.font, =
horizontalalignment=3D'right')
			if self.log_intensity:
				a.semilogy(x.ichannel,x.intensity,'k',y)
				a.set_xlim([0,len(x.ichannel)])
				a.set_ylabel(r'$log_{10} \rm{(Intensity [counts])}$', =
fontproperties=3Dself.font) 				a.set_xlabel(r'$\rm{channels}$', =
fontproperties=3Dself.font)
<snip>
Now, how can I apply the font to the subplot? In order to illustrate the =
problem a little bit better, I attached a part of a screen shot.
Here, with just one single subplot there is actually no problem and the =
plot would look absolutely stunning witht the default font. But with =
more than one subplot in the panel there is just not enough space to =
display all labels and the numbering on my screen.
I guess the solution is not half as complicated than the things I've =
tried. But since it is not really obvious to me, I am willing to =
contribute an example to this topic if there is not already one. Are =
there guidelines on how to file examples?
Regards,
Christian
From: Jochen V. <vo...@se...> - 2005年05月27日 10:42:53
Hello,
On Thu, May 26, 2005 at 02:25:53AM +0200, Marek Szczypinski wrote:
> form matplotlib.pylab import *
> ^
> SyntaxError: invalid syntax
you typed "form" instead of "from".
I hope this helps,
Jochen
--=20
http://seehuhn.de/
From: Eric E. <ems...@ob...> - 2005年05月27日 07:20:17
Hi,
a short note of support for the implementation of the 'None' feature in 
the facecolor,+...
It is very important to a few of us around here to be able to make 
scatter plots using unfilled markers.
Thanks a lot
Eric
-- 
===============================================================
Observatoire de Lyon ems...@ob...
9 av. Charles-Andre tel: +33 4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86
France http://www-obs.univ-lyon1.fr/eric.emsellem
===============================================================
From: John H. <jdh...@ac...> - 2005年05月27日 03:43:01
>>>>> "Chris" == Chris Barker <Chr...@no...> writes:
 Chris> Why use nx, rather than n? (or N, which is what I usually
 Chris> use). Actually, I usually use "import Numeric as N", I used
 Chris> Numeric long before I discovered matplotlib.
In my own scripts, I often use N to be the size of something. And I
eschew capital letters for ease of typing. I prefer nx since it
doesn't clash with many current scripts, is easy to type, and
resonates with the current name numerix which for better or worse is
the name mpl has used for Numeric/numarray integration. I'm not wed
to "nx" though.
 Chris> I'd say that this decision should be driven somewhat by
 Chris> what you want matplotlib to be. I see it as a plotting
 Chris> package, and I see Numeric (or SciPyBase?) as a numerical
 Chris> array package. Given that, option (1) is the way to go.
 Chris> However, I can see the strong appeal of an all in one
 Chris> package, al la Matlab. If we go this route (which is kind
 Chris> of the route at the moment), we'll see lot of questions on
 Chris> this list that have nothing to do with matplotlib, and
 Chris> everything to do with Numerix. WE have that already, of
 Chris> course.
 Chris> I really would like to see a nice, unified, set of packages
 Chris> for doing scientific/numeric work with Python. I think
 Chris> SciPy is the natural place for this, NOT matplotlib. My
 Chris> ideal version would have matplotlib as a sub-package of
 Chris> SciPy. It looks like we get to the grand-unification of
 Chris> Numeric, as SciPy Base, that that's a good start. I don't
 Chris> recall why you didn't make matplotlib a subpackage of SciPy
 Chris> in the first place, but I can understand that it happened
The historical reason was that scipy was considered hard to install.
matplotlib was pure python until 0.5 or something like that, and
depended only on Numeric and pygtk. Now mpl is fairly hard to install
and much more elaborate, and scipy is getting much easier to install.
If and when the time is right, and the powers that be want to integrate
mpl with scipy, I am happy to do it. I've also raised objections in
the past on the grounds that mpl release schedules are much faster
than scipy release schedules, but we're starting to get slow and
crotchety in our old age around here as well :-)
 Chris> that way, and honestly, there have been a lot of "plotting
 Chris> for SciPy" starts, and none of them has gotten to the
 Chris> usefulness of matplotlib, so you certainly did something
 Chris> right!
Thanks. I think the key is a relentless focus on making plots "look
good" and supporting all the reasonable features that people need.
That's what drove me away from other alternatives, at least. I mean,
as a self respecting open source/scientific python zealot, you're
nowhere if your plots look like crap.
 Chris> I just looked in the class docs, and I still can't see how
 Chris> to set something in an OO way, like the facecolor, for
 Chris> example:
 Chris> x.set('facecolor', 'r') maybe?
 Chris> I know I'd rather x.SetFaceColor('r') or something like
 Chris> that, but the above is OK too.
Use 
 x.set_facecolor('r')
All matplotlib properties work this way:
 OBJECT.set_PROPNAME(VAL). 
You should also be sure get your hands on a recent version of ipython;
TAB completion is your friend. In mpl CVS, in response to this
thread, I also added support for
 x.set(facecolor='r')
which has the advantage of supporting multiple property names
 x.set(facecolor='red', linewidth=2, alpha=0.5)
 Chris> Well, yes, for embedded use, but for quick scripts and
 Chris> interactive use, there should gbe an OO way to have your
 Chris> figure windows managed.
This sounds like what I call "pythonic matplotlib": using the pylab
interface to manage the GUI windows and such, while retaining a
pythonic coding style; eg, not relying on the current figure and axes
state. See examples/pythonic_matplotlib.py
 Chris> It's probably time for me to put up or shut up...I hope
 Chris> I'll get a chance to put up soon.
 Chris> Maybe a good start would be to go through the tutorial and
 Chris> users guide, and try to re-write all the examples in an OO
 Chris> manner, and see what happens.
Sounds like as good an idea as any.
JDH
From: John H. <jdh...@ac...> - 2005年05月27日 03:18:26
>>>>> "Gavin" == Gavin Huttley <gav...@an...> writes:
 Gavin> Hi, I want to produce a scatter plot with markers that are
 Gavin> not filled (empty markers). I note the following response
 Gavin> to an earlier query regarding line2D
There is no easy way to do this well. You can set the facecolor of
the scatter RegularPolyCollection -- note that the property names
follow the standard names of matplotlib.patches, not matplotlib.lines
(eg facecolor, not markerfacecolor). To make the face colors
"invisible" you need to set the facecolor to be the same as the Axes
background color (eg "white") -- but this will not always deliver the
desired results. As you suggest, you need a way of saying "do not
draw the facecolor at all", eg facecolor=None, which is different that
drawing a facecolor as the background. 
Unfortunately, None is overloaded in matplotlib, since it can mean
"use the default", which is a typical python idiom. But we often want
it to also mean "do not draw anything". As a result, some parts of
matplotlib have the ugly hack someprop=None to mean default and
someprop='None' to mean do nothing. This is slated for destruction,
when we implement a proper RC class that can distinguish between None
meaning use a default at class initialization time (which is a little
harder than using a default a module load time) and None meaning do
nothing.
It would not be too hard in the short term to add the string 'None'
hack for the facecolor of regular polygon collections. If this is
sufficiently important to you, file a support request at the
sourceforge site and we'll add it to the list of things to do.
JDH

Showing 8 results of 8

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