注解
点击 here 下载完整的示例代码
带定制彩色地图的拿破仑莫斯科行军的桑基¶
这个例子再现了一个著名的历史流程图:查尔斯·约瑟夫·米纳尔的地图描绘了拿破仑战争期间,拿破仑在1812年对俄罗斯进行了代价惨重的进军。
此图演示如何构建和使用自定义 matplotlib
彩色地图。要了解更多信息,请参阅 the matplotlib documentation .
Click here 要查看此webmap的交互式滚动panny版本,请使用 mplleaflet
. 了解更多 mplleaflet
,请参阅 the mplleaflet GitHub repo .

import geopandas as gpd
import geoplot as gplt
import matplotlib.pyplot as plt
import mplleaflet
from matplotlib.colors import LinearSegmentedColormap
napoleon_troop_movements = gpd.read_file(gplt.datasets.get_path('napoleon_troop_movements'))
colors = [(215/255, 193/255, 126/255), (37/255, 37/255, 37/255)]
cm = LinearSegmentedColormap.from_list('minard', colors)
gplt.sankey(
napoleon_troop_movements,
scale='survivors', limits=(0.5, 45),
hue='direction',
cmap=cm
)
fig = plt.gcf()
plt.savefig("minard-napoelon-russia.png", bbox_inches='tight', pad_inches=0.1)
# Uncomment and run the following line of code to save as an interactive webmap.
# mplleaflet.save_html(fig, fileobj='minard-napoleon-russia.html')
脚本的总运行时间: (0分0.947秒)