5 m" L- n, p* Q8 ?9 X# L
1. 海岸线 Basemap.drawcoaslines()7 h! Q6 A! T* t4 E4 G( o; y
2. 国界线 Basemap.drawcountries()6 r0 e3 J h) @
特别要注意国界线有无争议,此处主要说明basemap画国界线的用法,实际国界线以我们国家(中国)制作的地图为准! ; m: a4 z9 u; N9 D0 H( f5 n! ]
3. 州界线 Basemap.drawstates(),主要针对美洲
+ J) S' ~3 W, W5 F5 N5 r s import numpy as np
2 l" i- \& M% n# J import matplotlib.pyplot as plt/ M1 ^# p! L% }) C6 |' ^
from mpl_toolkits.basemap import Basemap
4 {2 x- q% f* G5 Z! @% ?
1 n, N, E; D2 \( {2 |6 b map = Basemap()
7 c# d) j: s$ ]! G" l. H map.drawcoastlines(color=r, linewidth=.5)
$ H( E! A" T0 `$ k- o+ c( V0 l map.drawcountries(color=g, linewidth=.25)
- G7 U) o7 Y; I0 i! j map.drawstates(color=b, linewidth=.2)1 ^, [+ t. Y3 b$ | B( |
map.drawparallels(circles=np.linspace(-90, 90, 7),- b+ [" ~* m! d# e2 P2 l7 `/ P
labels=[1, 0, 0, 0], color=gray)4 k+ _: [. E& R- @8 n# V W+ u9 O
map.drawmeridians(meridians=np.linspace(-180, 180, 13),
# ~4 T* b2 [7 E1 l5 Z labels=[0, 0, 0, 1], color=gray)' n' T* y4 G8 d L* k4 J) r
plt.show()
+ F) k3 D6 i. R5 }6 F : p7 E" g# `: u; J3 {( s6 y8 f6 t+ U
4. 用不同颜色填充海洋和陆地: u: Q# N- @! d9 U: x: o; C, F0 @$ G
4.1 海洋 Basemap.drawmapboundary(fill_color=#87CEEB)# t# N+ k+ H$ P; c- i8 u9 {
此处海洋颜色的天蓝色 1 a. B2 _& C1 l$ k) n
#87CEEB
& z& G- X5 K* \/ n3 { 4.2 陆地及湖泊 Basemap.fillcontinents(color=#808000, lake_color=#87CEEB)
. l, u9 x- E) S% e! f. {! E/ F 陆地为橄榄色
" t+ F2 N" ^! v+ H) u #808000 ; [0 T+ a9 [4 `# R, k, q
湖泊为天蓝色
4 H. B/ q6 J; h2 @# F6 E# y #87CEEB
4 w5 R( W! J5 `$ Z' q# j9 D4 Z$ Z0 O import numpy as np
* \9 V2 E% e) `! O2 \- e import matplotlib.pyplot as plt
( ]2 I3 U0 d6 [; I from mpl_toolkits.basemap import Basemap4 X5 S5 a4 f( N p+ z3 R) O3 l) R
: ]2 N9 Z6 k* A0 F9 h3 G map = Basemap()' p1 K: ~4 l4 [
map.drawcoastlines(color=r, linewidth=.5); Q& f8 C, g6 y' o: B9 A& _
map.drawcountries(color=g, linewidth=.25)
/ s& R( G+ b6 |0 { map.drawstates(color=b, linewidth=.2)
8 P8 R6 L- N/ Y* \ map.drawparallels(circles=np.linspace(-90, 90, 7),+ |# @5 q( v; ?9 l
labels=[1, 0, 0, 0], color=gray)
* N& j9 J) Y6 Q5 T; [0 `+ |" G map.drawmeridians(meridians=np.linspace(-180, 180, 13)," H5 `: [( u9 [; z$ D: d/ O1 H
labels=[0, 0, 0, 1], color=gray)) M2 S( W0 t3 E: ?2 P2 {
map.fillcontinents(color=#808000, lake_color=#87CEEB)
( W& c. |- `* ^: {& V map.drawmapboundary(fill_color=#87CEEB)6 ]" p" ^( M S S W2 E0 P
plt.show()
- Q3 ^1 V$ u0 @0 o% ^
# J$ `+ X4 t0 w* I1 j' {9 Q i3 s* O+ Q" X: F
' l- n+ T( E6 O9 f5 [7 D
* a. t* w4 H3 E* P6 X7 W
. V; r! B, |) ^* C" d8 U
|