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

Showing 10 results of 10

From: Sean H. <se...@sd...> - 2008年02月26日 22:41:36
Okay I've learnt a bit more about this:
http://img229.imageshack.us/img229/6467/scatterplot5st6.png
I need to explicitly make a new figure as well as a new axis, and put
the rc calls before the figure calls, rc changes only seem to take
effect on figures created afterwards. Also I was stupidly using the plot
function (for plotting lines) for a scatter plot, I've now discovered
the scatter function.
Things are pretty much how I want them now, but I still have a couple of
questions:
How do I get rid of the redundant ticks on the top and right edges?
Is there any way to stop some of my text labels from overlapping?
Why is there such a big gap between the plot itself and the axes ticks?
The scatter function seems to do this, but I don't see any option to
control the size of the gap. I wonder if I've done something weird like
create an axes within an axes. I don't mind the gap much, it's just
surprising, and could do with being much smaller to make the figure
easier to read.
Here's my new source code:
rc('xtick.major',size=8)
rc('xtick',direction='out')
rc('ytick.major',size=8)
rc('ytick',direction='out')
fig = figure(facecolor='white' )
axes(frameon=False)
title('Comparison of lower- and upper-bounds per function in week one
and week two')
l =
scatter(functions.lowerboundsweek1,functions.lowerboundsweek2,marker='s',color='g')
u =
scatter(functions.upperboundsweek1,functions.upperboundsweek2,marker='^',color='b')
legend((l,u),('Lower-bounds','Upper-bounds'),'best')
plot([0,1],[0,1],color='#999999',linestyle='--')
xlabel('Week 1')
ylabel('Week 2')
xticks(functions.upperboundsweek1+functions.lowerboundsweek1,'
'*len(functions.upperboundsweek1+functions.lowerboundsweek1))
yticks(functions.upperboundsweek2+functions.lowerboundsweek2,'
'*len(functions.upperboundsweek2+functions.lowerboundsweek2))
for function,x,y in
map(None,functions.shortnames,functions.upperboundsweek1,functions.upperboundsweek2):
 annotate(function,xy=(x,y),size=8,color='b') 
for function,x,y in
map(None,functions.shortnames,functions.lowerboundsweek1,functions.lowerboundsweek2):
 annotate(function,xy=(x,y),size=8,color='g') 
On Tue, 2008年02月26日 at 16:51 +0000, chombee wrote:
> I'm having a couple of problems drawing a basic relational scatter plot.
> (Specifically, it's called a dot-dash-plot in the book I have and is
> described as "framing the bivariate scatter with the marginal distribution
> of each variable.") The idea is that you have a bivariate scatter plot
> and use the two marginal frequency distributions of the data as the two
> axes.
> 
> 1. By setting the x and y tick length and using space characters as the
> tick labels I was able to get ticks only and no labels on the axes as I
> want. But these ticks appear along the top and right edges of the plot,
> as well as the left and bottom. Is there any way to get rid of the top
> and right ticks?
> 
> 2. I'm getting phantom numbers on my axes, the 0.2, 0.4, 0.6 etc. I
> don't know where these are coming from or what they measure (my data
> ranges from 0-7 on both axes, not 0-1).
> 
> 3. I want to label each data point with a string. I'm doing this with
> annotate but the strings sometimes overlap each other. Any idea how to
> avoid this?
> 
> Here's a PNG of my plot as it is:
> 
> http://img137.imageshack.us/img137/4015/scatterplotlk2.png
> 
> And here's the source:
> 
> # datax and datay are equal length lists of floats, the data I want to 
> # plot. labels is another equal length list containing the strings I 
> # want to label the data points with. All three lists are in the same
> # order.
> 
> axes(frameon=False)
> rc('xtick.major',size=8)
> rc('xtick',direction='out')
> xticks(datax,' '*len(datax))
> rc('ytick.major',size=8)
> rc('ytick',direction='out')
> yticks(datay,' '*len(datay))
> plot(datax,datay,'r.')
> plot([0,7],[0,7]) 
> xlabel('Proportion of total number of cards, week 1')
> ylabel('Proportion of total number of cards, week 2')
> title('Frequency of cards per function')
> for label,x,y in map(None,labels,datax,datay):
> annotate(function,xy=(x,y),size=8)
> 
> Thanks!
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jeff W. <js...@fa...> - 2008年02月26日 18:54:39
Lionel Roubeyrie wrote:
> Hi all,
> I'm sure it's a trivial question, but can't find any valid answer in the 
> basemap examples directory or with google : I have a georeferenced TIFF file 
> in 'lcc' projection, representing a little portion of France, and I need to 
> put it on a map, resets map limits to a closed portion of the map, and put 
> contours on it. I see how to initialise Basemap with the limits of the 
> raster, but not how to "make a zoom" in the map by specifing coordinates.
> Thanks for your help
> 
Lionel: You can use the set_xlim and set_ylim axes methods to manually 
'zoom' the plot. It has to be done after all the other plotting though, 
since all the Basemap methods (contour, imshow etc) will reset the axes 
limits to show the entire map region. 
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: chombee <ch...@ne...> - 2008年02月26日 16:55:04
I'm having a couple of problems drawing a basic relational scatter plot.
(Specifically, it's called a dot-dash-plot in the book I have and is
described as "framing the bivariate scatter with the marginal distribution
of each variable.") The idea is that you have a bivariate scatter plot
and use the two marginal frequency distributions of the data as the two
axes.
1. By setting the x and y tick length and using space characters as the
tick labels I was able to get ticks only and no labels on the axes as I
want. But these ticks appear along the top and right edges of the plot,
as well as the left and bottom. Is there any way to get rid of the top
and right ticks?
2. I'm getting phantom numbers on my axes, the 0.2, 0.4, 0.6 etc. I
don't know where these are coming from or what they measure (my data
ranges from 0-7 on both axes, not 0-1).
3. I want to label each data point with a string. I'm doing this with
annotate but the strings sometimes overlap each other. Any idea how to
avoid this?
Here's a PNG of my plot as it is:
http://img137.imageshack.us/img137/4015/scatterplotlk2.png
And here's the source:
# datax and datay are equal length lists of floats, the data I want to 
# plot. labels is another equal length list containing the strings I 
# want to label the data points with. All three lists are in the same
# order.
axes(frameon=False)
rc('xtick.major',size=8)
rc('xtick',direction='out')
xticks(datax,' '*len(datax))
rc('ytick.major',size=8)
rc('ytick',direction='out')
yticks(datay,' '*len(datay))
plot(datax,datay,'r.')
plot([0,7],[0,7]) 
xlabel('Proportion of total number of cards, week 1')
ylabel('Proportion of total number of cards, week 2')
title('Frequency of cards per function')
for label,x,y in map(None,labels,datax,datay):
 annotate(function,xy=(x,y),size=8)
Thanks!
From: Mark B. <ma...@gm...> - 2008年02月26日 14:45:25
To me it sounds like the bounding box is miscalculated when the axis are
turned off.
What you could do as a workaround, is add a fill to the figure that has the
exact same size as the axis box. Maybe then, when you turn the axis off it
will keep the same size? May be an ugly workaround, but worth a shot. You
also don't have to set the backgroundcolor of your plot anymore.
Mark
On Tue, Feb 26, 2008 at 3:22 PM, Jochen Voss <li...@se...> wrote:
> Hi Mark,
>
> On Tue, Feb 26, 2008 at 11:30:55AM +0100, Mark Bakker wrote:
> > As a workaround, can you just turn the axis box and ticks off?
> >
> > xticks([])
> > yticks([])
> > setp(ax,'frame_on',False)
> >
> > Or does that give the same problem?
>
> Unfortunately the problem also occurs when I replace the axis("off")
> with the lines suggested by you. The xticks commands work, but the
> setp breaks things again:
>
> with setp (broken output):
>
> voss@burmah [~/project/kalman/survey/fig2] grep -i BoundingBox out.eps
> %%BoundingBox: 1 300 326 417
> %%HiResBoundingBox: 1.923182 300.843797 325.923182 416.043797
>
> without setp (output looks ok but has an extra frame):
>
> voss@burmah [~/project/kalman/survey/fig2] grep -i BoundingBox out.eps
> %%BoundingBox: 143 338 468 454
> %%HiResBoundingBox: 143.999991 338.520012 467.999991 453.720012
>
> Is there anything else I can try?
>
> Many thanks,
> Jochen
> --
> http://seehuhn.de/
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFHxCC7f+iD8yEbECURAlbHAKCtb0KbmVSQJV3upSGfwp5ytP4J0gCfRKQm
> QvynbyKTxvsKQuAiy5EWyOI=
> =Wx7H
> -----END PGP SIGNATURE-----
>
>
From: Lionel R. <lro...@li...> - 2008年02月26日 14:40:29
Hi all,
I'm sure it's a trivial question, but can't find any valid answer in the 
basemap examples directory or with google : I have a georeferenced TIFF file 
in 'lcc' projection, representing a little portion of France, and I need to 
put it on a map, resets map limits to a closed portion of the map, and put 
contours on it. I see how to initialise Basemap with the limits of the 
raster, but not how to "make a zoom" in the map by specifing coordinates.
Thanks for your help
-- 
Lionel Roubeyrie - lro...@li...
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr
From: Jochen V. <li...@se...> - 2008年02月26日 14:23:06
Hi Mark,
On Tue, Feb 26, 2008 at 11:30:55AM +0100, Mark Bakker wrote:
> As a workaround, can you just turn the axis box and ticks off?
> 
> xticks([])
> yticks([])
> setp(ax,'frame_on',False)
> 
> Or does that give the same problem?
Unfortunately the problem also occurs when I replace the axis("off")
with the lines suggested by you. The xticks commands work, but the
setp breaks things again:
with setp (broken output):
 voss@burmah [~/project/kalman/survey/fig2] grep -i BoundingBox out.eps 
 %%BoundingBox: 1 300 326 417
 %%HiResBoundingBox: 1.923182 300.843797 325.923182 416.043797
without setp (output looks ok but has an extra frame):
 voss@burmah [~/project/kalman/survey/fig2] grep -i BoundingBox out.eps 
 %%BoundingBox: 143 338 468 454
 %%HiResBoundingBox: 143.999991 338.520012 467.999991 453.720012
Is there anything else I can try?
Many thanks,
Jochen
-- 
http://seehuhn.de/
From: Mark B. <ma...@gm...> - 2008年02月26日 10:31:01
As a workaround, can you just turn the axis box and ticks off?
xticks([])
yticks([])
setp(ax,'frame_on',False)
Or does that give the same problem?
From: Auré G. <aur...@ya...> - 2008年02月26日 08:47:21
>Date: 2008年2月22日 08:15:34 -0600
>From: "John Hunter" <jd...@gm...>
>Subject: Re: [Matplotlib-users] What is the proper way to set y tick
 > labels for a histogram ?
>To: " Aur? Gourrier " <aur...@ya...>
>Cc: mat...@li...
>Message-ID:
 > <88e...@ma...>
>Content-Type: text/plain; charset=ISO-8859-1
>
>On Fri, Feb 22, 2008 at 7:52 AM, Aur? Gourrier
><aur...@ya...> wrote:
>
>> Rather trivial... but instead of the plotting the counts n, I'd like to plot
>> the realtive percentage counts, i.e. n/len(x). I can't really use the option
>> normed = 1 which plots n/(len(x)*dbins). I guess the simplest way would be
>> to simply change the yticklabels (by dividing them by len(x)). The thing is
>> that I simply cannot find out how to do this...
>>
>> I tried using the axes.set_yticklabels() but doesn't work. I've also tried
>> to find the child containing the label but couldn't find it (not in Axes,
>> nor in YAxis etc...). I guess it must be a Text instance.
>
>You can set your own custom tick formatter:
>
>import matplotlib.ticker as ticker
>
>N = len(x)
>def fmt_percent(x, pos=None):
> return '%1.2f'%(float(x)/N)
>
>ax.xaxis.set_major_formatter(ticker.FuncFormatter(fmt_percent)). See
>http://matplotlib.sourceforge.net/examples/custom_ticker1.py for a
>complete example.
>
>JDH
Thanks, that's something I had not looked into yet and will definetly be useful for other pbs I had...
Cheers,
Aure
 ______________________________________________________________________________ 
Yahoo! Mail : un mail innovant avec Messenger compatible Windows Live + stockage illimité. http://mail.yahoo.fr 
From: Auré G. <aur...@ya...> - 2008年02月26日 08:43:57
Yep, that's what I did in the end... it also means that a simple argument could be added to the axes.hist() to do such operation, I described this in a previous post (see below, changes are in major cap).
Thanks for the tip,
Aure
 def hist(self, x, bins=10, RELPERCENT = 1, normed=0, bottom=None,
 align='edge', orientation='vertical', width=None,
 log=False, **kwargs):
 """
 if not self._hold: self.cla()
 n, bins = npy.histogram(x, bins, range=None, normed=normed)
 IF NOT NORMED AND RELPERCENT: N = N/FLOAT(LEN(X))
 if width is None: width = 0.9*(bins[1]-bins[0])
 if orientation == 'horizontal':
 patches = self.barh(bins, n, height=width, left=bottom,
 align=align, log=log)
 elif orientation == 'vertical':
 patches = self.bar(bins, n, width=width, bottom=bottom,
 align=align, log=log)
 else:
 raise ValueError, 'invalid orientation: %s' % orientation
 for p in patches:
 p.update(kwargs)
 return n, bins, cbook.silent_list('Patch', patches)
----- Message d'origine ----
De : Bernhard Voigt <ber...@gm...>
À : Auré Gourrier <aur...@ya...>
Cc : mat...@li...
Envoyé le : Dimanche, 24 Février 2008, 19h10mn 47s
Objet : Re: [Matplotlib-users] plot a histogram of relative percentage of data
Hi!
You could also use the bar method and do the histogram with numpy:
import numpy as n
import pylab as p
foo = n.random.normal(size=100)
p.hist(foo, 20)
p.twinx()
counts, bins = n.histogram(foo, 20)
counts = counts.astype(float)/len(foo)
width = (bins[1]-bins[0]) * .9
p.bar(bins ,counts, width=width, fc='r')
Cheers! Bernhard
On Fri, Feb 22, 2008 at 4:08 PM, Auré Gourrier <aur...@ya...> wrote:
Hi all,
In my latest post, I wanted to use the mpl.hist() function in a different way, i.e.:
x = datalist
bins= 100
hist(x,bins,normed=0) #returns a tupple (n,bins,patches)
Instead of ploting the number of counts n, I wanted to plot the relative percentage of counts, i.e. n/len(x). I can't really use the option normed=1 which returns n/(len(x)*dbin). In the axes.py module, this would simply mean adding an argument e.g. relpercent = 1. I added the code line to show how this could be done (in major cap). If this is useful, how could it be modified in the distribution ?
 def hist(self, x, bins=10, RELPERCENT = 1, normed=0, bottom=None,
 align='edge', orientation='vertical', width=None,
 log=False, **kwargs):
 """
 if not self._hold: self.cla()
 n, bins = npy.histogram(x, bins, range=None, normed=normed)
 IF NOT NORMED AND RELPERCENT: N = N/FLOAT(LEN(X))
 if width is None: width = 0.9*(bins[1]-bins[0])
 if orientation == 'horizontal':
 patches = self.barh(bins, n, height=width, left=bottom,
 align=align, log=log)
 elif orientation == 'vertical':
 patches = self.bar(bins, n, width=width, bottom=bottom,
 align=align, log=log)
 else:
 raise ValueError, 'invalid orientation: %s' % orientation
 for p in patches:
 p.update(kwargs)
 return n, bins, cbook.silent_list('Patch', patches)
 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 ______________________________________________________________________________ 
Yahoo! Mail : un mail innovant avec Messenger compatible Windows Live + stockage illimité. http://mail.yahoo.fr 
From: Michaël D. <mic...@la...> - 2008年02月26日 08:23:08
Hi list,
I have a set of data with 3 "columns" :
x = x coordinate of the point
y = y coordinate
z = temperature
I can't see how to set a different color for each point function of 
temperature value.
I have tried, which draw a colorfull beautiful "map", the color varying 
with the row rank of x (not what I want)
**********
 sqla="SELECT x, y, temperature FROM import_parcelle a WHERE 
dat_loc='" + date_traite + "' AND code_uc='" + code_uc + "' ORDER BY 
a.dateheure;"
 resa=db.query(sqla)
 data=resa.dictresult()
 x= [float(a["x"]) for a in data] # --> extraction de la colonne x
 y= [float(a["y"]) for a in data] # --> extraction de la colonne y
 z= [float(a["temperature"]) for a in data] # --> extraction de la 
colonne temperature
 scatter(x, y, c=arange(len(x)), cmap=cm.spring)
 title("Carte des temperatures(L/min)")
 xlim(min(x)-10,max(x)+10)
 ylim(min(y)-10,max(y)+10)
**********
What is the good way to do what I reach for ?
I have much trouble to know how to define the c parameter of scatter. I 
saw the "arrange" thing somewhere in internet, but don't understand what 
it is for.
Thanks in advance for your help.
Michael

Showing 10 results of 10

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