【Python】pygal初步使用
作者:互联网
import pygal
year_data = [str(i) for i in range(2011,2020)]
java_data = [17.89,18.29,20.45,19.28,20.35,21.23,19.98,20.23,19.5,20.0]
python_data = [4.89,4.29,4.45,4.28,5.35,6.23,6.98,6.23,6.5,6.0]
#创建图
bar = pygal.Bar()
bar.title = 'Java与Python历年的市场份额'
#添加数据
bar.add('Java语言的市场份额',java_data)
bar.add('Python语言的市场份额',python_data)
#配置
bar.x_labels = year_data
bar.x_title = '年份'
bar.y_title = '市场份额'
bar.x_label_rotation = 45
bar.legend_at_bottom = True
#输出到图片
bar.render_to_file("language.svg")
标签:市场份额,bar,title,Python,初步,pygal,data 来源: https://blog.csdn.net/xueshan007050/article/details/101156212