整理

上级 6d8318e5
"""
演示第三个图表: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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册