from pyecharts import options as opts
from pyecharts.charts import *
import pandas as pd
data = pd.read_excel('./截至2月17日22时37分疫情数据.xlsx', encoding='ansi')
mask = data["城市"] == data["省份"]
data = data.loc[mask , :]
res = data.loc[:,["城市","确诊数"]]
data_pair=res.values.tolist()
print(data_pair)
mapchina = Map()
mapchina.add(series_name = "疫情人数",
data_pair= data_pair,
maptype="china"
)
mapchina.set_global_opts(visualmap_opts=opts.VisualMapOpts(
is_piecewise=True,
pieces=[
{"min": 10001, "label": ">10000", "color": "#4b0101"},
{"max": 10000, "min": 5001, "label": ">5000", "color": "#4a0100"},
{"max": 5000, "min": 1001, "label": ">1000", "color": "#8A0808"},
{"max": 1000, "min": 500, "label": "500-1000", "color": "#B40404"},
{"max": 499, "min": 100, "label": "100-499", "color": "#DF0101"},
{"max": 99, "min": 10, "label": "10-99", "color": "#F78181"},
{"max": 9, "min": 1, "label": "1-9", "color": "#F5A9A9"},
{"max": 0, "label": "0", "color": "#FFFFFF"}]
))
mapchina.render("中国疫情分析图.html")
python练习----中国疫情图
最新推荐文章于 2022-08-17 14:51:20 发布