【发布时间】:2020-01-21 18:50:31
【问题描述】:
我正在尝试使用 shapefile 和数据框绘制地理数据,(按照此链接中的说明进行操作: https://towardsdatascience.com/lets-make-a-map-using-geopandas-pandas-and-matplotlib-to-make-a-chloropleth-map-dddc31c1983d) 通过合并它们,然后尝试绘制地理数据。
这里的map_df是geopandas读取的shapefile,df是地理统计的dataframe。
merged = map_df.set_index('NAME_3').join(df.set_index('City'))
variable = 'Rate'
vmin, vmax = 120, 220
fig, ax = plt.subplots(1, figsize=(10, 6))
merged.plot(column=variable, cmap = 'Blues', linewidth=0.8, ax=ax)
plt.show()
在链接中有 'edgecolor='0.8'' 变量,但它在我的代码中产生了 RGBA 错误,这就是我删除该部分的原因。 现在,即使我使用 plt.show() 它也不会显示情节,只会说:
<Figure size 432x288 with 0 Axes>
我能做些什么呢?谢谢。
【问题讨论】:
-
它是否适用于链接中显示的数据集?
-
我现在用链接中的数据进行了尝试,它显示了相同的结果:Figure size 432x288 with 0 Axes>
-
Mhh,我在从链接尝试笔记本时遇到this problem(似乎并非所有需要的文件都在 repo 中);这意味着我无法提供更多帮助。
标签: matplotlib figure geopandas