Python之路程序员我的Python自学之路

新手向——制作web图表(基于Python和GooPyChart

2016-10-27  本文已影响3315人  treelake

Creating Graphs with Python and GooPyCharts


第一张图

from gpcharts import figure
my_plot = figure(title='Demo')
my_plot.plot([1, 2, 10, 15, 12, 23])

运行后你的默认浏览器会打开并展示如下:


画条形图

from gpcharts import figure
# 获取图像对象并设置x,y轴的值
fig3 = figure()
xVals = ['Temps','2016-03-20','2016-03-21','2016-03-25','2016-04-01']
yVals = [['Shakuras','Korhal','Aiur'],[10,30,40],[12,28,41],[15,34,38],[8,33,47]]
# 添加标题和Y轴标注,画条形图
fig3.title = 'Weather over Days'
fig3.ylabel = 'Dates'
fig3.bar(xVals, yVals)

画散点图

from gpcharts import figure
#
my_fig = figure()
xVals = ['Dates','2016-03-20','2016-03-21','2016-03-25','2016-04-01'] # 第一个元素与上面不同
yVals = [['Shakuras','Korhal','Aiur'],[10,30,40],[12,28,41],[15,34,38],[8,33,47]]
#
my_fig.title = 'Scatter Plot'
my_fig.ylabel = 'Temps' # y轴标注做了修改
#
my_fig.scatter(xVals, yVals)

柱状图

from gpcharts import figure
#
my_fig = figure()
my_fig.title = 'Random Histrogram'
my_fig.xlabel = 'Random Values'
vals = [10, 40, 30, 50, 80, 100, 65]
my_fig.hist(vals)

其它

上一篇 下一篇

猜你喜欢

热点阅读