from matplotlib import pyplot as plt
import requests
import json
import matplotlib
headers = {
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.78',
}
url = 'http://222.178.203.72:19005/whst/63/=Zohzhmdvrzppzbnl//newsqa/v1/query/inner/publish/modules/list?modules=diseaseh5Shelf'
req = requests.get(url, headers=headers)
data = json.loads(req.text)
response = data['data']['diseaseh5Shelf']['areaTree'][0]['children']
name_list = []
heal_list = []
confirm_list = []
for i in response:
print(i)
#省份
name = i['name']
name_list.append(name)
print(name)
#确诊
confirm = i['total']['confirm']
confirm_list.append(confirm)
print(confirm)
dead = i['total']['dead']
#治愈
heal = i['total']['heal']
heal_list.append(heal)
# 设置中文字体和负号正常显示
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['axes.unicode_minus'] = False
plt.figure(figsize=(2080, 8), dpi=(100))
print(name_list)
print(confirm_list)
print(heal_list)
label_list = name_list # 横坐标刻度显示值
num_list1 = heal_list # 纵坐标值1
num_list2 = confirm_list # 纵坐标值2
x = range(len(num_list1))
# 绘制条形图
rects1 = plt.bar(x, height=num_list1, width=0.4, alpha=0.5, color='red', label='治愈人数')
rects2 = plt.bar([i+0.4 for i in x], height=num_list2, width=0.4, color='blue', label='确诊人数')
# 设置y轴属性
plt.ylim(0, 5000000)
plt.ylabel('数量')
# 设置x轴属性
plt.xticks([index+ 0 for index in x], label_list)
plt.xlabel("省份")
plt.title('各省治愈与死亡组合图')
plt.legend()
# 显示文本
for rect in rects1:
height = rect.get_height()
plt.text(rect.get_x() + rect.get_width() / 12, height + 5, str(height), ha='center', va='bottom')
for rect in rects2:
height = rect.get_height()
plt.text(rect.get_x() + rect.get_width() / 12, height + 5, str(height), ha='center', va='bottom')
plt.show()
plt.savefig("./3.svg")

yubotongxue
- 粉丝: 5
- 资源: 1
最新资源
- (源码)基于微控制器的吉他自动调音器.zip
- (源码)基于STM32微控制器的PCM数据分析项目.zip
- (源码)基于Go语言的抽奖小服务系统.zip
- (源码)基于ESP32和Ubidots的温湿度及CO2监测系统.zip
- (源码)基于Pythonwechaty框架的智能微信机器人.zip
- (源码)基于Arduino和FT810的彩虹合成器.zip
- (源码)基于STM32和Raspberry Pi的自动驾驶车辆系统.zip
- (源码)基于Python的图库管理系统.zip
- (源码)基于Arduino的电子发明家原型设计项目(Summer 2020版).zip
- (源码)基于Unity和FMOD的绘本游戏《会说话的点点》.zip
- (源码)基于Makefile的跨平台编译管理系统.zip
- (源码)基于STM32的USB风扇控制系统.zip
- (源码)基于Python的机器学习算法可视化实践系统.zip
- (源码)基于C语言和RTThread的ESPush W60X固件.zip
- (源码)基于Arduino和NodeMCU的智能街道照明系统.zip
- (源码)基于MQTT协议的智能隔尿垫系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论5