# coding: utf-8 from pyecharts import options as opts from pyecharts.charts import Bar, Line from pyecharts.globals import ThemeType import pandas as pd film=pd.read_csv('./dataCleanFile/film_all.csv') print(film['电影名'].to_list) print(film['票房'].to_list) print([i for i in film['评分']]) name_list=[i for i in film['电影名']] score=[i for i in film['评分']] num=[i for i in film['票房']] def overlap_bar_line(v1, v2, v4, v5): bar = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK)) # 这里可以选择主题 .add_xaxis(v1) .add_yaxis("票房", v2) .extend_axis( yaxis=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value}分"), interval=5 ) ) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts( title_opts=opts.TitleOpts(title="电影票房评分关系图"), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value}万票") ), xaxis_opts=opts.AxisOpts(name="电影名", axislabel_opts=opts.LabelOpts(rotate=-90, interval=0, font_size=10)) ) ) line = Line() line.add_xaxis(v4).add_yaxis("评分", v5, yaxis_index=1, ) bar.overlap(line) bar.render('./visualizationFile/bar_line_mixed_chart.html') v1 = name_list # x轴坐标 v2 = num # 票房 v4 = [i for i in range(0, 1000000)] # y轴 v5 = score # y对应的数据 overlap_bar_line(v1, v2, v4, v5)