一、柱形图系列
(一)单系列柱形图
from pyecharts.charts import Bar
from pyecharts import options as opts
import pandas as pd
data = pd.read_excel(r'C:\Users\仁义\Desktop\data.xlsx',sheet_name='Sheet1')
areas = data['地区']
cash_expense = data['现金消费支出Y']
wage_income = data['工资性收入X1']
other_income = data['其他收入X2']
areas_list = list(areas)
cash_expense_list = list(cash_expense)
wage_income_list = list(wage_income)
other_income_list = list(other_income)
chart = (Bar()
.add_xaxis(areas_list)
.add_yaxis("各省现金消费",
yaxis_data=cash_expense_list,
category_gap="50%",
)
.set_global_opts(title_opts=opts.TitleOpts(title="柱形图示例一", subtitle="各省现金消费支出与两类支出对比"))
)
chart.render('柱形图示例1.html')

(二)双系列柱形图
from pyecharts.charts import Bar
from pyecharts import options as opts
import pandas as pd
data = pd.read_excel(r'C:\Users\仁义\Desktop\data.xlsx',sheet_name='Sheet1')
areas = data['地区']
cash_expense = data['现金消费支出Y']
wage_income = data['工资性收入X1']
other_income = data['其他收入X2']
areas_list = list(areas)
cash_expense_list = list(cash_expense)
wage_income_list = list(wage_income)
other_income_list = list(other_income)
chart = (Bar()
.add_xaxis(areas_list)
.add_yaxis("各省现金消费",
yaxis_data=cash_expense_list,
category_gap='0%',
)
.add_yaxis('工资性收入',
yaxis_data=wage_income_list,
category_gap='0%',
)
.set_global_opts(title_opts=opts.TitleOpts(title="柱形图示例1", subtitle="各省现金消费支出与两类支出对比"))
)
chart.render('柱形图示例2.html')
