问题描述
我正在使用 geoplot
's kdeplot
函数来显示不同时间段的内核密度图(又名热图)。
fig,axs = plt.subplots(n_rows,n_cols,figsize=(20,10))
for ax,t in zipped(axs.flatten(),periods):
# df is a GeoPandas dataframe
data = df.loc[(df['period'] == t),['id','geometry']]
# heatmap plot
gplt.kdeplot(
data,clip=africa.geometry,cmap='Reds',shade=True,cbar=True,ax=ax)
gplt.polyplot(africa,ax=ax,zorder=1)
ax.set_title(int(t))
输出如下图
我希望能够为我的整个数据集定义一个通用比例(无论时间如何),然后我可以在 kdeplot
中使用它并作为我的子图的独特图例。
我知道我的数据在不同年份具有不同的密度,但我试图找到一种可用于每个数据的通用值。
我认为 levels
参数将是我正在寻找的参数(即对我的周期使用相同的密度等比例,例如 [0.2,0.4,0.6,0.8,1]
)。
但是,当我将它与 cbar=True
结合使用来显示图例时,每个图例的值都不同于其他图例(以及 levels
向量)。
我做错了吗?
如果没有,我需要手动设置cbar吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)