重庆疫情分布图

旧城冷巷雨未停 提交于 2020-02-10 20:30:22

重庆疫情分布图

代码参考:Jian__xiao

https://blog.csdn.net/xiaojian0907/article/details/104131754

2020-2-10 16:08
在这里插入图片描述
九龙坡区附近区域局部放大图:

编程语言:python3

安装第三方库:pip install pyecharts

注意:需要更新pyecharts

使用: pip install -U pyecharts.

from pyecharts.charts import Map
from pyecharts import options as opts
ny_number = 0
other_number = 3
ny_location = ["万州区", "江北区", "九龙坡区", "垫江县", "云阳县", "渝中区", "合川区",
               "开州区", "忠县", "两江新区", "长寿区", "綦江区", "奉节县","渝北区",
               "潼南区", "大足区", "巫溪县", "石柱县", "丰都县", "巫山县", "璧山区",
               "铜梁区", "南岸区", "荣昌区", 
    "大渡口区", "永川区", "巴南区", "江津区", "梁平区", "高新区", "涪陵区", "城口县", "黔江区",
               "沙坪坝区", 
        "彭水县", "秀山县", "武隆区", "酉阳县", "万盛经开区"]
number_patient = [98, 24, 20, 20, 20,20, 18,18,18,16,15,15,14,13,
                  13,13,12,12,9,9,8,8,8,8,7,5,5,4,4,4,3,2,2,2,2,1,1,1,1
                  ]

for i in number_patient:
    ny_number += i
all_number = ny_number + other_number

ny_list = [[ny_location[i], number_patient[i]] for i in range(len(ny_location))]
ny_map = Map()

ny_map.set_global_opts(
    title_opts=opts.TitleOpts(title="重庆市新型冠状病毒疫情分布地图 "
                                    "共计: {0}例, 市内: {1}例, 外省进入: {2}例".format(all_number, ny_number, other_number)),
    visualmap_opts=opts.VisualMapOpts(max_=100, is_piecewise=True,
                                      pieces=[
                                          {"max": 100, "min": 51, "label": "51-100", "color": "#840611"},
                                          {"max": 50, "min": 26, "label": "50-26", "color": "#c50719"},
                                          {"max": 25, "min": 13, "label": "13-25", "color": "#f41f33"},
                                          {"max": 12, "min": 7, "label": "7-12", "color": "#f76e7a"},
                                          {"max": 6, "min": 3, "label": "3-6", "color": "#fab8be"},
                                          {"max": 2, "min": 0, "label": "0-2", "color": "#ffffff"},
                                      ]
                                      )
    )
ny_map.add("", ny_list, maptype="重庆")
ny_map.render("重庆疫情地图.html")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!