import json
from pyecharts.charts import Map
from pyecharts.options import *
f=open("D:/疫情.txt","r",encoding="UTF-8")
data=f.read()
f.close()
yiqing_dict=json.loads(data)
shannxi=yiqing_dict["areaTree"][0]["children"][15]["children"]
list=[]
for sx_list in shannxi:
sx_name=sx_list["name"]+"市"
sx_confirm=sx_list["total"]["confirm"]
list.append((sx_name,sx_confirm))
# gt
map=Map()
map.set_global_opts(
title_opts=TitleOpts(title="陕西省疫情分析图",pos_bottom="3%",pos_left="center"),
visualmap_opts=VisualMapOpts(
is_show=True,
is_piecewise=True,
pieces=[
{"min": 1, "max": 9, "lable": "1-9", "color": "#0dce1c"},
{"min": 10, "max": 49, "lable": "10-49", "color": "#1050e6"},
{"min": 50, "max": 99, "lable": "50-99", "color": "#ca0e5b"},
{"min": 100, "max":200, "lable": "100-200", "color": "#ff0a00"}
]
)
)
map.add("陕西省疫情图",list,"陕西")
map.render("陕西省疫情.html")
python陕西省疫情
最新推荐文章于 2024-09-15 22:31:42 发布