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





Showing 9 results of 9

From: Michael H. <mh...@us...> - 2008年03月04日 14:47:24
Jeff - I think the way GMT does it would be okay - they have a 
latitude of true scale, which I usually choose as the center latitude 
of the map.
I was thinking we should allow people to choose the "simple" or 
"fancy" options. Do you think it will be okay to have the height of 
the bar and the text offset be relative to the length of it? I 
suppose if the height becomes a problem, people could use the yoffset 
keyword...
--Mike
On Mar 4, 2008, at 6:05 AM, Jeff Whitaker wrote:
> Michael Hearne wrote:
>> Jeff - That would replicate the "simple" scale-bar from GMT. 
>> Below is my not-complete attempt at replicating the "fancy" scale 
>> bar. It would need some options for specifying different units 
>> (miles, nautical miles, etc.) and perhaps some more attention to 
>> spacing of the text from the scale bar and tick marks...
>>
>> --Mike
>
> Mike: Very nice! Do you want the scale to show the true distance 
> on the earth (in which case the labels will vary depending on where 
> the label is placed), or the distance in map projection coordinates 
> (in which case the labels are constant)? Or perhaps a lat/lon 
> value could be given to specify where the scale is true?
>
> -Jeff
>>
>> from numpy import *
>> from matplotlib.toolkits.basemap import Basemap, pyproj
>> from pylab import *
>> # add drawscale method to Basemap class.
>> class Basemap2(Basemap):
>> def drawscale(self,lon,lat,length,yoffset=None):
>> """draw a fancy map scale from lon-length/2,lat-yoffset to
>> lon-length/2,lat-yoffset, label it with actual distance in 
>> km"""
>> length = length*1000 #input length is km
>>
>> #we need 5 sets of x coordinates (in map units)
>> #center of scale
>> xc,yc = self(lon,lat)
>> #left edge of scale
>> lon1,lat1 = self(xc-length/2,yc,inverse=True)
>> x1,y1 = self(lon1,lat1)
>> #quarter scale
>> lon2,lat2 = self(xc-length/4,yc,inverse=True)
>> x2,y2 = self(lon2,lat2)
>> #three quarter scale
>> lon3,lat3 = self(xc+length/4,yc,inverse=True)
>> x3,y3 = self(lon3,lat3)
>> #right edge of scale
>> lon4,lat4 = self(xc+length/2,yc,inverse=True)
>> x4,y4 = self(lon4,lat4)
>> if yoffset is None: yoffset = 0.1*length
>>
>> #plot top line
>> ytop = yc+yoffset/2
>> ybottom = yc-yoffset/2
>> ytick = ybottom - yoffset/2
>> ytext = ytick - yoffset/2
>> m.plot([x1,x4],[ytop,ytop],color='k')
>> #plot bottom line
>> m.plot([x1,x4],[ybottom,ybottom],color='k')
>> #plot left edge
>> m.plot([x1,x1],[ybottom,ytop],color='k')
>> #plot right edge
>> m.plot([x4,x4],[ybottom,ytop],color='k')
>>
>> #make a filled black box from left edge to 1/4 way across
>> fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],'k')
>> #make a filled white box from 1/4 way across to 1/2 way across
>> fill([x2,xc,xc,x2,x2],[ytop,ytop,ybottom,ybottom,ytop],'w')
>> #make a filled white box from 1/2 way across to 3/4 way across
>> fill([xc,x3,x3,xc,xc],[ytop,ytop,ybottom,ybottom,ytop],'k')
>> #make a filled white box from 3/4 way across to end
>> fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],'w')
>> #plot 3 tick marks at left edge, center, and right edge
>> m.plot([x1,x1],[ytick,ybottom],color='k')
>> m.plot([xc,xc],[ytick,ybottom],color='k')
>> m.plot([x4,x4],[ytick,ybottom],color='k')
>>
>> #label 3 tick marks
>> text(x1,ytext,'%d' % (0),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>> text(xc,ytext,'%d' % (round((length/2)/1000)),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>> text(x4,ytext,'%d' % (round((length)/1000)),\
>> horizontalalignment='center',\
>> verticalalignment='top',\
>> fontsize=9)
>>
>> #put units on top
>> text(xc,ytop+yoffset/2,'km',\
>> horizontalalignment='center',\
>> verticalalignment='bottom',\
>> fontsize=9)
>>
>> # setup of basemap ('lcc' = lambert conformal conic).
>> # use major and minor sphere radii from WGS84 ellipsoid.
>> m = Basemap2 
>> (llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
>> rsphere=(6378137.00,6356752.3142),\
>> resolution='l',area_thresh=1000.,projection='lcc',\
>> lat_1=50.,lon_0=-107.)
>> # draw coastlines and political boundaries.
>> m.drawcoastlines()
>> m.fillcontinents()
>> # draw parallels and meridians.
>> # label on left, right and bottom of map.
>> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
>> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
>> # draw a line from x1,y to x2,y and label it with distance in km.
>> length = 3000 #kilometers
>> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
>> lon1,lat1 = m(x1,y1,inverse=True)
>> m.drawscale(lon1,lat1,length)
>> title('a fancy map scale')
>> show()
>>
>>
>>
>>
>> ------------------------------------------------------
>> Michael Hearne
>> mh...@us... <mailto:mh...@us...>
>> (303) 273-8620
>> USGS National Earthquake Information Center
>> 1711 Illinois St. Golden CO 80401
>> Senior Software Engineer
>> Synergetics, Inc.
>> ------------------------------------------------------
>>
>>
>
>
> -- 
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
------------------------------------------------------
Michael Hearne
mh...@us...
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------
From: Michael D. <md...@st...> - 2008年03月04日 13:11:29
Like your last question, I think you're using the current release's 
documentation (0.91.2) with an old release (probably 0.90.1 or earlier).
pyplot did not exist in 0.90.1, but I believe everything that is now in 
pyplot used to be in pylab, so you could just import that instead.
Cheers,
Mike
Ssebuliba, J, Mnr <jo...@su...> wrote:
> Hi there,
> 
> When I use;
> 
> import matplotlib.pyplot as p, 
> 
> I get an error message;
> 
> ImportError: No module named pyplot. So, how am I supposed to get these missing modules?
> 
> Please note: I am using Linux (Ubuntu-gusty)!
> 
> Regards,
> JOE.
> 
> -------------------------------------------------------------------------
> 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
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2008年03月04日 13:10:12
It looks as if you're using 0.90.1. All of these issues are fixed in 
0.91.2. If you can upgrade, that's probably your best bet.
Or, if you have all the requirements, you can set "text.usetex" to True 
in your matplotlibrc which will use the "real" TeX on your system to 
typeset math -- that should support your expression.
Ssebuliba, J, Mnr <jo...@su...> wrote:
> Hi all,
> 
> When I use;
> text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$', fontsize=20)
> 
> I get an error message below;
> File "/usr/lib/python2.5/site-packages/matplotlib/mathtext.py", line 616, in _get_info
> raise ValueError('unrecognized symbol "%s"' % sym)
> ValueError: unrecognized symbol "\mathr", unrecognized symbol "\mathcal"
0.90.1 was much less TeX-like in its mathtext support, and therefore 
doesn't support \mathrm, \mathcal etc.. You can, however do:
text(0.6, 0.6, r'$\cal{A}\rm{sin}(2 \omega t)$', fontsize=20)
which works for me.
> When I replace \mathrm with \mbox or \text, the error message I get is basically the same, only that this time, the last line appears as;
> unrecognized symbol "\mbox", unrecognized symbol "\text"
\mbox and \text aren't supported by the built-in mathtext in any version.
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Jeff W. <js...@fa...> - 2008年03月04日 13:06:08
Michael Hearne wrote:
> Jeff - That would replicate the "simple" scale-bar from GMT. Below is 
> my not-complete attempt at replicating the "fancy" scale bar. It 
> would need some options for specifying different units (miles, 
> nautical miles, etc.) and perhaps some more attention to spacing of 
> the text from the scale bar and tick marks...
>
> --Mike
Mike: Very nice! Do you want the scale to show the true distance on 
the earth (in which case the labels will vary depending on where the 
label is placed), or the distance in map projection coordinates (in 
which case the labels are constant)? Or perhaps a lat/lon value could 
be given to specify where the scale is true?
-Jeff
>
> from numpy import *
> from matplotlib.toolkits.basemap import Basemap, pyproj
> from pylab import *
> # add drawscale method to Basemap class.
> class Basemap2(Basemap):
> def drawscale(self,lon,lat,length,yoffset=None):
> """draw a fancy map scale from lon-length/2,lat-yoffset to
> lon-length/2,lat-yoffset, label it with actual distance in km"""
> length = length*1000 #input length is km
>
> #we need 5 sets of x coordinates (in map units)
> #center of scale
> xc,yc = self(lon,lat)
> #left edge of scale
> lon1,lat1 = self(xc-length/2,yc,inverse=True)
> x1,y1 = self(lon1,lat1)
> #quarter scale
> lon2,lat2 = self(xc-length/4,yc,inverse=True)
> x2,y2 = self(lon2,lat2)
> #three quarter scale
> lon3,lat3 = self(xc+length/4,yc,inverse=True)
> x3,y3 = self(lon3,lat3)
> #right edge of scale
> lon4,lat4 = self(xc+length/2,yc,inverse=True)
> x4,y4 = self(lon4,lat4)
> 
> if yoffset is None: yoffset = 0.1*length
>
> #plot top line
> ytop = yc+yoffset/2
> ybottom = yc-yoffset/2
> ytick = ybottom - yoffset/2
> ytext = ytick - yoffset/2
> m.plot([x1,x4],[ytop,ytop],color='k')
> #plot bottom line
> m.plot([x1,x4],[ybottom,ybottom],color='k')
> #plot left edge
> m.plot([x1,x1],[ybottom,ytop],color='k')
> #plot right edge
> m.plot([x4,x4],[ybottom,ytop],color='k')
>
> #make a filled black box from left edge to 1/4 way across
> fill([x1,x2,x2,x1,x1],[ytop,ytop,ybottom,ybottom,ytop],'k')
> #make a filled white box from 1/4 way across to 1/2 way across
> fill([x2,xc,xc,x2,x2],[ytop,ytop,ybottom,ybottom,ytop],'w')
> #make a filled white box from 1/2 way across to 3/4 way across
> fill([xc,x3,x3,xc,xc],[ytop,ytop,ybottom,ybottom,ytop],'k')
> #make a filled white box from 3/4 way across to end
> fill([x3,x4,x4,x3,x3],[ytop,ytop,ybottom,ybottom,ytop],'w')
> 
> #plot 3 tick marks at left edge, center, and right edge
> m.plot([x1,x1],[ytick,ybottom],color='k')
> m.plot([xc,xc],[ytick,ybottom],color='k')
> m.plot([x4,x4],[ytick,ybottom],color='k')
>
> #label 3 tick marks
> text(x1,ytext,'%d' % (0),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
> text(xc,ytext,'%d' % (round((length/2)/1000)),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
> text(x4,ytext,'%d' % (round((length)/1000)),\
> horizontalalignment='center',\
> verticalalignment='top',\
> fontsize=9)
>
> #put units on top
> text(xc,ytop+yoffset/2,'km',\
> horizontalalignment='center',\
> verticalalignment='bottom',\
> fontsize=9)
>
> # setup of basemap ('lcc' = lambert conformal conic).
> # use major and minor sphere radii from WGS84 ellipsoid.
> m = 
> Basemap2(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
> rsphere=(6378137.00,6356752.3142),\
> resolution='l',area_thresh=1000.,projection='lcc',\
> lat_1=50.,lon_0=-107.)
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.fillcontinents()
> # draw parallels and meridians.
> # label on left, right and bottom of map.
> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
> # draw a line from x1,y to x2,y and label it with distance in km.
> length = 3000 #kilometers
> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
> lon1,lat1 = m(x1,y1,inverse=True)
> m.drawscale(lon1,lat1,length)
> title('a fancy map scale')
> show()
>
>
>
>
> ------------------------------------------------------
> Michael Hearne
> mh...@us... <mailto:mh...@us...>
> (303) 273-8620
> USGS National Earthquake Information Center
> 1711 Illinois St. Golden CO 80401
> Senior Software Engineer
> Synergetics, Inc.
> ------------------------------------------------------
>
>
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Ssebuliba, J, M. <jo...@su...> - 2008年03月04日 12:25:58
Hi there,
When I use;
import matplotlib.pyplot as p, 
I get an error message;
ImportError: No module named pyplot. So, how am I supposed to get these missing modules?
Please note: I am using Linux (Ubuntu-gusty)!
Regards,
JOE.
From: Ssebuliba, J, M. <jo...@su...> - 2008年03月04日 09:18:15
Hi all,
When I use;
text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$', fontsize=20)
I get an error message below;
File "/usr/lib/python2.5/site-packages/matplotlib/mathtext.py", line 616, in _get_info
 raise ValueError('unrecognized symbol "%s"' % sym)
ValueError: unrecognized symbol "\mathr", unrecognized symbol "\mathcal"
When I replace \mathrm with \mbox or \text, the error message I get is basically the same, only that this time, the last line appears as;
unrecognized symbol "\mbox", unrecognized symbol "\text"
How should I fix this problem?
Many thanks,
JOE.
From: sa6113 <s.p...@gm...> - 2008年03月04日 08:27:34
How use numpy in order to create Image object from string ?
.
.
.
size = canvas.get_width_height( )
buffer = canvas.tostring_rgb()
img = numpy.empty(size,numpy.uint32)
img = numpy.fromstring(buffer,numpy.uint32)
img is an array , but I want an Image object (without using PIL ).
sa6113 wrote:
> 
> Would you please help me ?
> I want to load data to Image (QImage) from String or binary String without
> using PIL module .
> 
-- 
View this message in context: http://www.nabble.com/how-load-data-to-Image-from-String--tp15784115p15822415.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: sa6113 <s.p...@gm...> - 2008年03月04日 05:22:12
Is there anyway to use the modules that are already on the system, or those
that are pure Python ?
I want to show a plot that draws with backend agg in my GUI , I mean in a
specified place that its type is Qlabel or QFrame , I don't want to save the
plot befor show it.
Christopher Barker wrote:
> 
> sa6113 wrote:
>> Would you please help me ?
>> I want to load data to Image (QImage) from String or binary String
>> without
>> using PIL module .
> 
> you can load data straight into a numpy array with numpy.fromstring() -- 
> if it's in an easy format (RGB, RGBA), then you should be able to go 
> from there.
> 
> What do you want to do with the image data?
> 
> -CHB
> 
> 
> -- 
> Christopher Barker, Ph.D.
> Oceanographer
> 
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
> 
> Chr...@no...
> 
> -------------------------------------------------------------------------
> 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
> 
> 
-- 
View this message in context: http://www.nabble.com/how-load-data-to-Image-from-String--tp15784115p15820587.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Adam G. <kef...@gm...> - 2008年03月04日 04:48:22
Hi, I'm trying to use the values of a contour plot to evaluate the min/max
along a given axis in order to marginalize a 2d distribution. This
effectively amounts to doing the same thing asked for in this post:
http://sourceforge.net/mailarchive/message.php?msg_id=47505681.8030306%40hawaii.edu
I think there's an easier way to do this:
val = contour(xRange,yRange,delchi2,[1])
t = asarray(val.collections[0].get_verts())
because the example given in the above post actually return a list, not a
numpy array (unless I did it wrong).
However, even though the above works, it was poorly documented and took
about an hour of googling / guess-and-checking to get to it. Either the
documentation should be improved a little (e.g. explain what "collections"
really means) or some more transparent means of returning the contour data
should be available.
So, the question: is there any easier way to do the above? Is this actually
the easy method?
Thanks,
Adam

Showing 9 results of 9

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