底图更改邻居国家/地区的颜色

时间:2015-01-28 13:43:53

标签: python-2.7 matplotlib matplotlib-basemap

from mpl_toolkits.basemap import Basemap

fig = plt.figure(figsize=(20,10))  # predefined figure size, change to your liking. 
# But doesn't matter if you save to any vector graphics format though (e.g. pdf)
ax = fig.add_axes([0.05,0.05,0.9,0.85])

# These coordinates form the bounding box of Germany
bot, top, left, right = 5.87, 15.04, 47.26, 55.06 # just to zoom in to only Germany
map = Basemap(projection='merc', resolution='l',
    llcrnrlat=left,
    llcrnrlon=bot,
    urcrnrlat=right,
    urcrnrlon=top)
map.readshapefile('./DEU_adm/DEU_adm1', 'adm_1', drawbounds=True)  # plots the state boundaries, read explanation below code
map.drawcoastlines()
map.fillcontinents(color='lightgray')

long1 = np.array([ 13.404954,  11.581981,   9.993682,   8.682127,   6.960279,
6.773456,   9.182932,  12.373075,  13.737262,  11.07675 ,
7.465298,   7.011555,  12.099147,   9.73201 ,   7.628279,
8.801694,  10.52677 ,   8.466039,   8.239761,  10.89779 ,
8.403653,   8.532471,   7.098207,   7.216236,   9.987608,
7.626135,  11.627624,   6.852038,  10.686559,   8.047179,
8.247253,   6.083887,   7.588996,   9.953355,  10.122765])

lat1 = np.array([ 52.520007,  48.135125,  53.551085,  50.110922,  50.937531,
51.227741,  48.775846,  51.339695,  51.050409,  49.45203 ,
51.513587,  51.455643,  54.092441,  52.375892,  51.36591 ,
53.079296,  52.268874,  49.487459,  50.078218,  48.370545,
49.00689 ,  52.030228,  50.73743 ,  51.481845,  48.401082,
51.960665,  52.120533,  51.47512 ,  53.865467,  52.279911,
49.992862,  50.775346,  50.356943,  49.791304,  54.323293])

x, y = map(long1, lat1)
map.plot(x,y,'.')  # Use the dot-marker or use a different marker, but specify the `markersize`.

如何改变德国邻居的颜色。

状态基础的数据是从shapefile获得的。这些可以从例如Global Administrative Areas(本网站上的内容仅可用于非商业用途)

0 个答案:

没有答案