py-mo-pygal
jzztf opened this issue · 0 comments
jzztf commented
数据可视化---pygal
http://www.pygal.org/en/stable/documentation/first_steps.html
import pygal
fruits = ['Apples', 'Cherries', 'Pears', 'Oranges', 'Apples', 'Bananas', 'Strawberries']
numbers = ['73', '85', '14', '52', '152', '23', '98']
# 创建pygal条形图实例
bar_chart = pygal.Bar()
# 为图表添加数据
bar_chart.add("Fruits", [int(x) for x numbers])
# instance.add(title,values,**kargs)
# values为数值!!整型或浮点型都可以
# add方法运行一次,图表相应添加一个实例
# 为图表添加x轴标签
bar_chart.x_labels = fruits
# 添加说明
bar_chart.title = "图表标题"
bar_chart.x_title = "X轴标题"
bar_chart.y_title = "Y轴标题"
# 在浏览器中查看(pip install xml)
bar_chart.render_in_browser()
# help(bar_char)查看更多信息