基本思想:使用Python的pyecharts包进行中国疫情的动态图绘制;
链接:https://pan.baidu.com/s/15oaBrsSGL_YNikRlwwaZZw
提取码:c460
复制这段内容后打开百度网盘手机App,操作更方便哦
复制这段内容后打开百度网盘手机App,操作更方便哦
import pandas as pd
from pylab import *
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
import os
from glob import glob
from pyecharts import Line
from pyecharts import Map
line = Line("折线图-面积图示例")
attr=[]
value=[]
y0_axis=[]
x0_axis=[]
file_list=glob("F:\\project54\\*.csv")
for file in file_list:
print(file)
name=os.path.split(file)[1]
name=os.path.splitext(name)[0]
df = pd.read_csv(file,index_col=False,encoding='gbk')
#print(str(y0_axis))
x0_axis=list(df.head(0))[2:-2]
print(len(x0_axis),x0_axis)
for indexs in df.index:
if re.search(list(df.loc[indexs].values[0:-1])[0],'湖北'):
y0_axis=list(df.loc[indexs].values[0:-1])[2:-1]
print(len(y0_axis),len(x0_axis))
attr.append(list(df.loc[indexs].values[0:-1])[0])
value.append(list(df.loc[indexs].values[0:-1])[-1])
line.add("Hubei", x0_axis, y0_axis, is_fill=True, mark_point=["max", "min","average"], line_opacity=0.2, area_opacity=0.4, symbol=None)
line.show_config()
line.render('hubei.html')
map = Map("Map 结合 VisualMap 示例", width=1200, height=600)
map.add("", attr, value, visual_range=[0, 900], maptype='china', is_visualmap=True,visual_text_color='#000')
map.show_config()
map.render('china.html')