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 5 results of 5

From: Christopher B. <Chr...@no...> - 2008年03月31日 23:16:08
Hi all,
as far as I can tell, matplotlib.py2exe_datafiles is broken with the 
latest release. Is it getting fixed?
Also, there is a LOT of stuff in there -- is there a way to strip out 
the stuff you may not need for a particular application? I'm using MPl 
embedded in a wxPython app, and I don't need the icons, etc, nor do a 
need a bunch of fonts. I suppose it's just disk space, though.
One more question:
In mpl-data, there are a bunch of images and fonts. There are also 
subdirectories "images", and "fonts", with a bunch more? My the 
different places for these?
-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...
From: Christopher B. <Chr...@no...> - 2008年03月31日 17:51:33
Gregor Thalhammer wrote:
> for repainting a matplotlib figure, every time a repaint is done also 
> the bitmap is rerendered:
> 
> backend_wx.py/_onPaint():
> ...
> # Render to the bitmap
> self.draw(repaint=False)
> ...
You're quite right -- the paint handler should only blit to the 
PaintDC, which, in this case, is:
self.gui_repaint(drawDC=wx.PaintDC(self))
However, if I comment out that call to self.draw, I get a blank screen 
in a wxmpl app of mine. If I re-size the Window, then it gets draw 
('cause the OnSize handler is re-drawing).
Also, in the same app, even when I call Figure.draw(), I'm notgetting it 
updated.
So it looks like there is code counting on this extra draw call.
I'll poke into it a bit more, it may be somethign we can fix in wxmpl, 
if there aren't issues elsewhere.
-Chris
> This also affects the behaviour of the wxagg backend.
yes, it looks like _onPaint is inherited from FigureCanvasWx, so it's 
the same issue.
 Rerendering and
> therefore also repainting gets quite slow if, e.g., images are included 
> in the figure. I can see this by simply dragging another window across 
> the matplotlibfigure. Commenting out the rerendering I get a much 
> smoother behaviour. I could not observe problems except that sometimes 
> some parts of the figure are not properly repainted if the matplotlib 
> figure is in the background (I only tested the wxagg backend). Therefore 
> it seems that this rerendering every time a repaint is performed is not 
> really necessary and should be avoided.
> 
> I tested this on matplotlib 0.91.2 on WinXP, Python 2.5, wx 2.8.7. I 
> checked that in the current svn version the _onPaint() function is 
> unchanged.
> 
> Gregor
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
-- 
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...
From: Nick S. <mat...@ni...> - 2008年03月31日 16:08:20
Hi,
I am new to this list, so forgive me if this has been asked before. I am
trying to do a radial plot and the following code does not seem to work:
# ------< START CODE >-------
import pylab
import matplotlib
fig = pylab.figure(figsize=(8,8))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
pylab.hold(True)
ax.plot([4.189, 4.188],[41.347, 41.058], color = 'green', lw=1)
#ax.plot([4.199, 4.188],[41.347, 41.058], color = 'green', lw=1)
ax.set_rmax(80) # scale plot
pylab.show()
# ------< END CODE >-------
When you run this, the entire background of the plot turns green. If you
comment out the first "ax.plot" and uncomment the line below it, it works as
expected. Any ideas as to what is going on? Is there some kind of limitation
to the smallest line allowed? Thanks for any help!
---Nick
From: Jeff W. <js...@fa...> - 2008年03月31日 14:56:17
KURT PETERS wrote:
> Thanks,
> I'll give that a try. I had seen the other example, but had a very 
> difficult time figuring out what this line does:
> x, y = zip(*m.cities)
Kurt:
See the docs for the zip built-in python function at 
http://docs.python.org/lib/built-in-funcs.html.
x,y = zip(*<list of tuples> is just the reverse of zip(x,y)
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/103702
>
> Frankly, I have google'ed possibilities, but "zip" is so 
> ubiquitous, that figuring out what it really does in THIS case is 
> difficult. Do you have a good explanation of why that's necessary? (I 
> saw nothing in the shapefile docs that talks to zipping files.
> I'm not sure why 'enumerate' doesn't work?
> I will give the annotate a try with the code you provided and see if 
> that works. Also, is there a particular reason why you chose '10' 
> for your zorder? Use of that parameter is not especially clear in the 
> documentaion - perhaps having a table with what other thing's zorders 
> are would help.
There's nothing magic about 10. It just has to be greater than 1 so the 
dots come out on top of the continent fill. If you leave out the call 
to fillcontinents, you don't need the zorder at all.
>
> As for suggestions about the shapefile doc/usability. I think it's 
> hard to handle such a multidimensional data format in a workable 
> sense. I'm getting the hang of it. It's hard to have visualization 
> of what the shapefile looks like. Perhaps some kind of auto schematic 
> (think Visio or graphviz) function would be neat to show how things 
> are mapped in the shapefile and something that tells you line, poly, 
> point, etc., in the blocks and how they map to a built-in pylib class?
The thing is, shapefiles are not really a format I use a lot. I tend to 
work on things that I actually use the most.
> If you had more of a wiki format to the documentation, I know I 
> would have modified the docs to make things clearer as I've been 
> muddling through. Perhaps making a tutorial. It's especially true 
> since I've been teaching myself about shapefiles as well.
That's a good idea. Making a tutorial has always been on my to-do list, 
but I never seem to get the time. It would be a great if someone would 
step up and contribute one.
-Jeff
>
> Kurt
> ----Original Message Follows----
> From: Jeff Whitaker <js...@fa...>
> To: KURT PETERS <pet...@ms...>
> CC: mat...@li...
> Subject: Re: [Matplotlib-users] Basemaps - shapefile import/display 
> for points
> Date: 2008年3月31日 06:27:50 -0600
>
> KURT PETERS wrote:
>> OK Jeff, Thanks for your help on the previous question - I had been 
>> playing with different projections and resolutions, so that's why the 
>> comments didn't match the actual settings in the procedure calls. 
>> Now for a "real" problem:
>>
>> I'm trying to plot the cities from this web site: 
>> http://nationalatlas.gov/metadata/citiesx020.faq.html
>> using that shapefile, which uses points, not polygons (it took a long 
>> time to figure out that difference from the example of fillstates.py).
>> http://nationalatlas.gov/atlasftp.html?openChapters=chpref#chpref
>>
>> While I think I'm loading everything and displaying everything 
>> correctly, the values are not plotting right, nor do they seem 
>> realistic.
>>
>> For instance the point values look like this (which really can't be 
>> right):
>>
>> Shape num Fairbanks, coords=(42082.855349492747, 5336578.2660309337)
>> Shape num Anchorage, coords=(-442294.67146861833, 5031412.4918638617)
>>
>> print shp_info - the second value shows to use points not polys:
>> (35432, 1, [-174.20294189453125, 17.711706161499023, 0.0, 0.0], 
>> [178.87460327148437, 71.290138244628906, 0.0, 0.0])
>> Dictionaries:
>> ['STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 
>> 'FIPS', 'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
>> STATE_FIPS = 02, NAME = Anchorage, POP_2000=260283, FEATURE = County 
>> Seat, COUNTY=Anchorage Borough, STATE=AK, FIPS=02020, CITIESX020 = 
>> 194, FIPS55=03000, DISPLAY=0, POP_RANGE=250,000 - 499,999
>>
>>
>>
>> Here's the code:
>> ===============
>> import pylab as p
>> import numpy
>> from matplotlib.toolkits.basemap import Basemap as Basemap
>> from matplotlib.colors import rgb2hex
>> from matplotlib.patches import Polygon
>>
>> # Lambert Conformal map of lower 48 states.
>> # create new figure
>> fig=p.figure()
>> m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
>> projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c')
>> shp_info = 
>> m1.readshapefile(r'C:\Python25\Lib\basemap-0.9.9.1\examples\citiesx020','states',drawbounds=True) 
>>
>>
>> ax=p.gca()
>>
>> #define SHPT_POINT 1 Points
>> #define SHPT_ARC 3 Arcs (Polylines, possible in parts)
>> #define SHPT_POLYGON 5 Polygons (possible in parts)
>> #define SHPT_MULTIPOINT 8 MultiPoint (related points)
>> print shp_info
>> print m1.states_info[0].keys()
>> seqnum={}
>> criteriatodisplay=[]
>> ii=0
>> for shapedict in m1.states_info:
>> if int(shapedict['POP_2000'])>100000:
>> #'STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 
>> 'FIPS', 'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
>> print 'STATE_FIPS = %s, NAME = %s, POP_2000=%s, FEATURE = %s, 
>> COUNTY=%s, STATE=%s, FIPS=%s, CITIESX020 = %s, FIPS55=%s, DISPLAY=%s, 
>> POP_RANGE=%s' %\
>> (str(shapedict['STATE_FIPS']), str(shapedict['NAME']), 
>> str(shapedict['POP_2000']), str(shapedict['FEATURE']), 
>> str(shapedict['COUNTY']), str(shapedict['STATE']), 
>> str(shapedict['FIPS']), str(shapedict['CITIESX020']), 
>> str(shapedict['FIPS55']), str(shapedict['DISPLAY']), 
>> str(shapedict['POP_RANGE']))
>> seqnum[shapedict['CITIESX020']]=shapedict['NAME']
>> criteriatodisplay.append(shapedict['CITIESX020'])
>> ii+=1
>>
>> print ii
>>
>> for nshape,seg in enumerate(m1.states):
>> if nshape in criteriatodisplay:
>> print 'Shape num %s, coords=%s' % (seqnum[nshape], seg)
>> h= [seg[0]*0.000278,seg[1]*0.000278]
>>
>> ax.annotate(seqnum[nshape],h)
>> m1.drawcoastlines()
>> m1.fillcontinents()
>> m1.drawcountries()
>> m1.drawstates()
>> m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0])
>> m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1])
>> p.title('Test Cities')
>> p.show()
>> =============
>> Regards,
>> Kurt
>>
>>
>
> Kurt: I had no trouble plotting them with this script:
>
> m = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
> projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c')
> shp_info = m.readshapefile('citiesx020','cities')
> x, y = zip(*m.cities)
> m.drawcoastlines()
> m.drawcountries()
> m.fillcontinents()
> m.scatter(x,y,2,'b',marker='o',faceted=False,zorder=10)
> p.show()
>
> This is adapted from the plotcities.py example, which was designed for 
> point files (fillstates.py was designed for polygon files). In this 
> case, m.cities is just a list of x,y coordinates. I don't know why 
> ax.annotate wasn't working for you.
>
> I know the shapefile stuff is non-intuitive and could use a lot of 
> work. Perhaps when you can offer some suggestions for the docs, or 
> for re-designing the interface.
>
> -Jeff
>
>
> -- 
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
>
>
-- 
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: Jeff W. <js...@fa...> - 2008年03月31日 12:28:04
KURT PETERS wrote:
> OK Jeff, Thanks for your help on the previous question - I had been playing 
> with different projections and resolutions, so that's why the comments 
> didn't match the actual settings in the procedure calls. Now for a "real" 
> problem:
>
> I'm trying to plot the cities from this web site: 
> http://nationalatlas.gov/metadata/citiesx020.faq.html
> using that shapefile, which uses points, not polygons (it took a long time 
> to figure out that difference from the example of fillstates.py).
> http://nationalatlas.gov/atlasftp.html?openChapters=chpref#chpref
>
> While I think I'm loading everything and displaying everything correctly, 
> the values are not plotting right, nor do they seem realistic.
>
> For instance the point values look like this (which really can't be right):
>
> Shape num Fairbanks, coords=(42082.855349492747, 5336578.2660309337)
> Shape num Anchorage, coords=(-442294.67146861833, 5031412.4918638617)
>
> print shp_info - the second value shows to use points not polys:
> (35432, 1, [-174.20294189453125, 17.711706161499023, 0.0, 0.0], 
> [178.87460327148437, 71.290138244628906, 0.0, 0.0])
> Dictionaries:
> ['STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 'FIPS', 
> 'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
> STATE_FIPS = 02, NAME = Anchorage, POP_2000=260283, FEATURE = County Seat, 
> COUNTY=Anchorage Borough, STATE=AK, FIPS=02020, CITIESX020 = 194, 
> FIPS55=03000, DISPLAY=0, POP_RANGE=250,000 - 499,999
>
>
>
> Here's the code:
> ===============
> import pylab as p
> import numpy
> from matplotlib.toolkits.basemap import Basemap as Basemap
> from matplotlib.colors import rgb2hex
> from matplotlib.patches import Polygon
>
> # Lambert Conformal map of lower 48 states.
> # create new figure
> fig=p.figure()
> m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
> projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c')
> shp_info = 
> m1.readshapefile(r'C:\Python25\Lib\basemap-0.9.9.1\examples\citiesx020','states',drawbounds=True)
>
> ax=p.gca()
>
> #define SHPT_POINT 1 Points
> #define SHPT_ARC 3 Arcs (Polylines, possible in parts)
> #define SHPT_POLYGON 5 Polygons (possible in parts)
> #define SHPT_MULTIPOINT 8 MultiPoint (related points)
> print shp_info
> print m1.states_info[0].keys()
> seqnum={}
> criteriatodisplay=[]
> ii=0
> for shapedict in m1.states_info:
> if int(shapedict['POP_2000'])>100000:
> #'STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 'FIPS', 
> 'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
> print 'STATE_FIPS = %s, NAME = %s, POP_2000=%s, FEATURE = %s, 
> COUNTY=%s, STATE=%s, FIPS=%s, CITIESX020 = %s, FIPS55=%s, DISPLAY=%s, 
> POP_RANGE=%s' %\
> (str(shapedict['STATE_FIPS']), str(shapedict['NAME']), 
> str(shapedict['POP_2000']), str(shapedict['FEATURE']), 
> str(shapedict['COUNTY']), str(shapedict['STATE']), str(shapedict['FIPS']), 
> str(shapedict['CITIESX020']), str(shapedict['FIPS55']), 
> str(shapedict['DISPLAY']), str(shapedict['POP_RANGE']))
> seqnum[shapedict['CITIESX020']]=shapedict['NAME']
> criteriatodisplay.append(shapedict['CITIESX020'])
> ii+=1
>
> print ii
>
> for nshape,seg in enumerate(m1.states):
> if nshape in criteriatodisplay:
> print 'Shape num %s, coords=%s' % (seqnum[nshape], seg)
> h= [seg[0]*0.000278,seg[1]*0.000278]
>
> ax.annotate(seqnum[nshape],h)
> m1.drawcoastlines()
> m1.fillcontinents()
> m1.drawcountries()
> m1.drawstates()
> m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0])
> m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1])
> p.title('Test Cities')
> p.show()
> =============
> Regards,
> Kurt
>
> 
Kurt: I had no trouble plotting them with this script:
m = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
 projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c')
shp_info = m.readshapefile('citiesx020','cities')
x, y = zip(*m.cities)
m.drawcoastlines()
m.drawcountries()
m.fillcontinents()
m.scatter(x,y,2,'b',marker='o',faceted=False,zorder=10)
p.show()
This is adapted from the plotcities.py example, which was designed for 
point files (fillstates.py was designed for polygon files). In this 
case, m.cities is just a list of x,y coordinates. I don't know why 
ax.annotate wasn't working for you.
I know the shapefile stuff is non-intuitive and could use a lot of 
work. Perhaps when you can offer some suggestions for the docs, or for 
re-designing the interface. 
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Showing 5 results of 5

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