1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pandas as pd
from pyecharts.charts import Bar
from pyecharts import options as opts
file_path = './温度与降水量蒸发量.xlsx'
data_frame = pd.read_excel(file_path)
# x_data = list(data_frame['月份'])[0:5]
# y_data =list(data_frame['蒸发量'])[0:5]
show_x_data = []
show_y_data = []
for i in range(len(data_frame['温度'])):
if data_frame['温度'][i] > 10 :
show_y_data.append(data_frame['月份'][i])
show_x_data.append(data_frame['温度'][i])
bar = (
Bar(init_opts=opts.InitOpts(width='800px',height='600px'))
.set_global_opts(
title_opts=opts.TitleOpts(title='hello pyecharts',subtitle='俺是副标题',pos_left='center',text_align='center'),
legend_opts=opts.LegendOpts(pos_left='left'),
tooltip_opts=opts.TooltipOpts(axis_pointer_type='cross',border_color="yellow",border_width=3,trigger_on='click')
# visualmap_opts=opts.VisualMapOpts(is_show=True,pos_top='300px')
)
.add_xaxis(show_y_data)
.add_yaxis("冯越",show_x_data)
.render()
)