疫情地图
话不多说,直接上代码
# coding:utf-8
from pyecharts.charts import Map
import pyecharts.options as opt
import requests
import json
# 获取数据
result = requests.get('https://gwpre.sina.cn/interface/fymap2020_data.json').text
result = json.loads(result)
# print(result)
# 清洗数据
data = list()
for i in result['data']['list']:
data.append((i['name'], i['value']))
# print(data)
# 绘制中国地图
new_map = Map()
new_map.set_global_opts(
title_opts=opt.TitleOpts('疫情地图',
subtitle='数据来源于新浪网',
subtitle_link='http://www.sina.cn'),
visualmap_opts=opt.VisualMapOpts(max_=10000, is_piecewise=True))
new_map.add('确诊', data, maptype='china')
new_map.render('20200528.html')
效果图: