疫情地圖

疫情地圖

話不多說,直接上代碼

# 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')

效果圖:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章