0 R3 L! Q+ h& @6 m" | 1. 海岸线 Basemap.drawcoaslines()
6 z2 E8 k# Z6 e6 g! U* a 2. 国界线 Basemap.drawcountries() [3 d! r* V' A. h& R U
特别要注意国界线有无争议,此处主要说明basemap画国界线的用法,实际国界线以我们国家(中国)制作的地图为准!
2 p, z/ E7 N! Q 3. 州界线 Basemap.drawstates(),主要针对美洲
( e* z9 R/ z: D" A/ Z: [& ~" `/ ` import numpy as np
+ m$ P: W! ]9 s; g, ^( D" m; ? import matplotlib.pyplot as plt
- r; T' A' ~: W0 U* t5 x3 K" \ from mpl_toolkits.basemap import Basemap
+ W3 u; u! _1 b, H) [, n4 Z0 k
& j" M% [9 \; Y8 d+ c" { map = Basemap()5 c7 j9 K+ h7 [7 A* H( [! x
map.drawcoastlines(color=r, linewidth=.5)
4 M) S( N2 f4 ]/ R4 G map.drawcountries(color=g, linewidth=.25), c1 D- I6 c7 n4 P. r( u6 q h E, Z: H
map.drawstates(color=b, linewidth=.2)
7 C, L& X! s2 y+ ?% a map.drawparallels(circles=np.linspace(-90, 90, 7),- u' w8 j' ]7 n! U
labels=[1, 0, 0, 0], color=gray)' y2 f8 k0 A c* }+ `
map.drawmeridians(meridians=np.linspace(-180, 180, 13),! y' j0 B( x2 o' A! Z3 f
labels=[0, 0, 0, 1], color=gray)2 B+ H; s) R3 _1 \) w. S; \
plt.show() 0 E2 Q0 Y/ H, P/ I- {2 _3 e
2 z( a1 e- F) a3 c9 V) ?
4. 用不同颜色填充海洋和陆地! D& v1 M2 c: [& N/ g
4.1 海洋 Basemap.drawmapboundary(fill_color=#87CEEB)) M. D; o8 _& j7 \& x7 a- ~
此处海洋颜色的天蓝色
2 _. K8 T# j' q* B3 A #87CEEB
: |( h- n/ O7 {$ H: } 4.2 陆地及湖泊 Basemap.fillcontinents(color=#808000, lake_color=#87CEEB)2 E6 q. B$ N5 s# J8 I* ?) @/ C
陆地为橄榄色
+ F1 N6 _! d1 k; h [" H #808000
8 \8 {- N* Z N4 Y0 u 湖泊为天蓝色 . J- e" B- {& I1 Q) l; h1 A9 m$ L7 `
#87CEEB
& J( X+ p+ f3 {) e; w' M import numpy as np
+ r$ m. c! [* r% D! i. b import matplotlib.pyplot as plt
4 D; j. c) B! i. B; \6 q from mpl_toolkits.basemap import Basemap. L$ c$ V) D6 k, |+ o8 U
& c% S5 F% ^9 E6 D
map = Basemap()( t* e$ I! y. \7 [
map.drawcoastlines(color=r, linewidth=.5)# `7 n/ ~- s- G: O
map.drawcountries(color=g, linewidth=.25), K1 d- @* [; X6 N6 B6 A; K6 d' v3 z
map.drawstates(color=b, linewidth=.2)
) v7 K5 H5 I1 d map.drawparallels(circles=np.linspace(-90, 90, 7),$ F8 \/ u! ~' L+ h2 V' k8 K4 e
labels=[1, 0, 0, 0], color=gray)
2 X9 K3 A5 w; w map.drawmeridians(meridians=np.linspace(-180, 180, 13),
6 q% g7 x7 d6 K5 V7 O2 t# S labels=[0, 0, 0, 1], color=gray)
1 u. u9 M$ |9 \6 x+ A# N+ ` map.fillcontinents(color=#808000, lake_color=#87CEEB), ?; L& y4 K, n4 j( u0 y
map.drawmapboundary(fill_color=#87CEEB)8 s( H9 T' C. O1 }' Q1 D4 y2 B
plt.show() ! H. h# k3 V/ S; ]
4 p1 ?4 Q. y; _- S% t
" d+ ~( w5 D9 L, r% \# O" x6 C
# \1 M" x; t& X& D/ d
4 i& R3 K; t% i n# d
8 t" [% P% I4 U* @ |