# 需要导入模块: from matplotlib import pylab [as 别名]

# 或者: from matplotlib.pylab import rcParams [as 别名]

def quantiles_MoranI_Plot(data_df,zipPolygon):

caseWeekly_unstack=data_df['CasesWeekly'].unstack(level=0)

zip_codes= gpd.read_file(zipPolygon)

data_df_zipGPD=zip_codes.merge(caseWeekly_unstack,left_on='zip', right_on=caseWeekly_unstack.index)

# print(data_df_zipGPD.head())

# print(data_df_zipGPD.describe())

print(data_df_zipGPD.columns)

weeks=idx_weekNumber=data_df.index.get_level_values('Week Number')

weeks=np.unique(weeks)

nrows=2

ncols=math.ceil(len(weeks)/nrows)

fig, axes = plt.subplots(nrows=nrows, ncols=ncols,figsize = (30,15))

for i in range(nrows):

for j in range(ncols):

# print("_"*50)

# print(str(weeks[i*ncols+j]))

try:

plt.rcParams.update({'font.size': 5})

ax = axes[i,j]

data_df_zipGPD.plot(ax=ax, column=weeks[i*ncols+j], cmap='OrRd', scheme='quantiles', legend=True,)

ax.set_title('daily cases %s Quintiles'%weeks[i*ncols+j])

ax.axis('off')

leg = ax.get_legend()

leg.set_bbox_to_anchor((0.8, 0.15, 0.16, 0.2))

data_df_zipGPD.apply(lambda x: ax.annotate(s=x.zip, xy=x.geometry.centroid.coords[0], ha='center'),axis=1)

leg = ax.get_legend()

leg.set_bbox_to_anchor((0., 0., 0.2, 0.2))

except:

pass

plt.tight_layout()

W=ps.lib.weights.Queen(data_df_zipGPD.geometry)

W.transform = 'R'

valArray=data_df_zipGPD[weeks].to_numpy()

valArray_fillNan=bfill(valArray).T

valArray_fillNan[np.isnan(valArray_fillNan)]=0

# print(valArray_fillNan,valArray_fillNan.shape)

mits=[Moran(cs,W) for cs in valArray_fillNan]

res = np.array([(mi.I, mi.EI, mi.seI_norm, mi.sim[974]) for mi in mits])

# print(res)

fig, ax = plt.subplots(nrows=1, ncols=1,figsize = (10,5) )

ax.plot(weeks, res[:,0], label='Moran\'s I')

#plot(years, res[:,1], label='E[I]')

ax.plot(weeks, res[:,1]+1.96*res[:,2], label='Upper bound',linestyle='dashed')

ax.plot(weeks, res[:,1]-1.96*res[:,2], label='Lower bound',linestyle='dashed')

ax.set_title("Global spatial autocorrelation for Covid-19-cases",fontdict={'fontsize':15})

# ax.set_xlim(weeks)

# plt.axhline(y=0, color='gray', linestyle='--',)

ax.legend()

#Moran's I >0表示空间正相关性,其值越大,空间相关性越明显,Moran's I <0表示空间负相关性,其值越小,空间差异越大,否则,Moran's I = 0,空间呈随机性。

#spatial markov about the explanation ref:蒲英霞,马荣华,葛莹,黄杏元.基于空间马尔可夫链的江苏区域趋同时空演变[J]. 地理学报.2005-09-23

#ref:https://pysal.org/pysal/generated/pysal.explore.giddy.markov.Spatial_Markov.html

python中rcparams_Python pylab.rcParams方法代码示例相关推荐

  1. python中shelf_Python cmds.shelfLayout方法代码示例

    本文整理汇总了Python中maya.cmds.shelfLayout方法的典型用法代码示例.如果您正苦于以下问题:Python cmds.shelfLayout方法的具体用法?Python cmds ...

  2. python中summary_Python summary_pb2.Summary方法代码示例

    本文整理汇总了Python中tensorflow.core.framework.summary_pb2.Summary方法的典型用法代码示例.如果您正苦于以下问题:Python summary_pb2 ...

  3. python中weekday_Python calendar.weekday方法代码示例

    本文整理汇总了Python中calendar.weekday方法的典型用法代码示例.如果您正苦于以下问题:Python calendar.weekday方法的具体用法?Python calendar. ...

  4. python中close_Python pool.close方法代码示例

    本文整理汇总了Python中multiprocessing.pool.close方法的典型用法代码示例.如果您正苦于以下问题:Python pool.close方法的具体用法?Python pool. ...

  5. python中callable_Python abc.Callable方法代码示例

    本文整理汇总了Python中collections.abc.Callable方法的典型用法代码示例.如果您正苦于以下问题:Python abc.Callable方法的具体用法?Python abc.C ...

  6. python中permute_Python layers.Permute方法代码示例

    本文整理汇总了Python中keras.layers.Permute方法的典型用法代码示例.如果您正苦于以下问题:Python layers.Permute方法的具体用法?Python layers. ...

  7. python中opener_Python request.build_opener方法代码示例

    # 需要导入模块: from six.moves.urllib import request [as 别名] # 或者: from six.moves.urllib.request import bu ...

  8. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  9. python asyncio future_Python asyncio.isfuture方法代码示例

    本文整理汇总了Python中asyncio.isfuture方法的典型用法代码示例.如果您正苦于以下问题:Python asyncio.isfuture方法的具体用法?Python asyncio.i ...

最新文章

  1. html图片上传选择文件后的事件,bootstrap-fileinput插件,上传成功后事件
  2. linux沙箱隔离_Linux沙箱技术介绍
  3. 124_Power PivotPower BI DAX优化计算最大连续次数
  4. 远程桌面连接服务器,提示身份验证错误,要求的函数不受支持,但又找不到加密Oracle修正
  5. 云栖大会上阿里巴巴没说的数字经济逻辑
  6. 《MYSQL必知必会》—19~21.插入、更新、删除数据;创建、更新、删除表
  7. echarts使用记录(二)legend翻页,事件,数据集,设置y轴最大/小值,让series图形从右侧出往左移动...
  8. 联想小新air13装双系统_联想小新Pro 13黑苹果详细安装教程
  9. idea 如何查看jdk源码
  10. 笔记本 - 常用快捷键 word 笔记
  11. 史上最全的定位攻略,您应该知道的定位方法。
  12. 从原理层面掌握@RequestAttribute、@SessionAttribute的使用【享学Spring MVC】
  13. 九章算术卷第八 方程
  14. spring配置文件中的p和c命名空间的使用
  15. Redis中地理位置GEO模块,非常便捷的来查找附近的人或物
  16. 【它山之玉】博士三年发表论文回顾—科学网马臻
  17. QS排名十年对比:美国大学最稳,中国大学进步最快
  18. 六、ResNet网络详细解析(超详细哦)
  19. 深度强化学习面试问题集锦
  20. 凤凰os进不去图形界面_开机选择凤凰系统就停留在这个界面了怎么办?急在线等!...

热门文章

  1. Seafood Legacy Co., Ltd.宣布2021年东京可持续海鲜峰会开放报名
  2. 餐饮业改善寻源战略的6个实践
  3. 淘宝店小蜜配置手册——店小蜜模式的设置
  4. IT界的一些朗朗上口的名言
  5. 面试前必备的 JavaScript 基础知识梳理总结
  6. oracle的协处理器,oracle sparc t7 和sparc m7 服务器架构.pdf
  7. 无聊之作:Karry解数独程序
  8. 不小心清空了回收站怎么恢复?恢复误删除的方法
  9. mysql删除所有男生_My SQL常用操作汇总
  10. 人脸识别:即使不上传任何照片依然能跟踪你的个人信息