diff --git "a/09_\345\217\257\350\247\206\345\214\226\346\241\210\344\276\213/11_csdn\347\272\242\345\214\205\347\264\257\350\256\241\351\207\221\351\242\235\346\216\222\345\220\215.py" "b/09_\345\217\257\350\247\206\345\214\226\346\241\210\344\276\213/11_csdn\347\272\242\345\214\205\347\264\257\350\256\241\351\207\221\351\242\235\346\216\222\345\220\215.py" index 69c9a1155472601469a502ab59ccc976e83cc44b..6501f11edca2af20601c411cff0c85197f371eaa 100644 --- "a/09_\345\217\257\350\247\206\345\214\226\346\241\210\344\276\213/11_csdn\347\272\242\345\214\205\347\264\257\350\256\241\351\207\221\351\242\235\346\216\222\345\220\215.py" +++ "b/09_\345\217\257\350\247\206\345\214\226\346\241\210\344\276\213/11_csdn\347\272\242\345\214\205\347\264\257\350\256\241\351\207\221\351\242\235\346\216\222\345\220\215.py" @@ -1,6 +1,4 @@ -""" -演示第三个图表:GDP动态柱状图开发 -""" + from pyecharts.charts import Bar, Timeline from pyecharts.options import * from pyecharts.globals import ThemeType @@ -14,9 +12,6 @@ data_lines = f.readlines() f.close() # 删除第一条数据 data_lines.pop(0) -# 将数据转换为字典存储,格式为: -# { 年份: [ [国家, gdp], [国家,gdp], ...... ], 年份: [ [国家, gdp], [国家,gdp], ...... ], ...... } -# { 1960: [ [美国, 123], [中国,321], ...... ], 1961: [ [美国, 123], [中国,321], ...... ], ...... } # 先定义一个字典对象 data_dict = {} bar_colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF', '#C0C0C0', '#800080'] @@ -51,13 +46,6 @@ for year in sorted_year_list: x_data.reverse() y_data.reverse() - # bar.add_xaxis(x_data) - # for i, (country, gdp,color) in enumerate(zip(x_data, y_data,bar_color_list)): - # bar.add_yaxis( - # series_name=country, - # yaxis_data=[gdp], - # label_opts=opts.LabelOpts(position="right", color=bar_color_list[i]), - # ) bar.add_xaxis(x_data) bar.add_yaxis("红包数据", y_data, label_opts=LabelOpts(position="right")) # bar.add_yaxis("红包数据", y_data, label_opts=LabelOpts(position="right"), itemstyle_opts=ItemStyleOpts(color=bar_color_list))