【撞墙】那啥,反正已经蛋痛过一次了……再来画图吧

下午很蛋痛的用正则表达分析网页去了,然后刚才发现原来饭否提供的API里面有直接搜索的API,OTL……
蛋痛并继续蛋痛吧,吧频率图的程序补完- -,依赖pygooglechart @ pygooglechart.slowchop.com

然后不负责任的贴代码走人,output_fqcd是前一个程序的输出- – Python不支持unicode的模块名么?

# -*- coding: UTF-8 -*-

from output_fqcd import fanfou_data

mapdata = map(lambda data: data['time'][2:7] ,fanfou_data)

def reduce_func(d,r):
    if r in d:
        d[r] = d[r]+1
    else:
        d[r] = 1
    return d

data = reduce(reduce_func,mapdata,{})

new_data = []
for x,y in data.iteritems():
    new_data.append((x,y))

new_data.sort(lambda a,b: cmp(a[0],b[0]))

print(new_data)

x_data = []
y_data = []

for item in new_data:
    x_data.append(item[0])
    y_data.append(item[1])

from pygooglechart import Chart
from pygooglechart import StackedVerticalBarChart
from pygooglechart import Axis

min_y = 0 #min(data)
max_y = max(y_data)

chart = StackedVerticalBarChart(600, 375, y_range=[min_y, max_y])

chart.set_title('Search Count of "番茄操蛋"')
chart.add_data(y_data)

chart.set_bar_width(30)

left_axis = range(min_y, max_y + 1, max_y/10)
chart.set_axis_labels(Axis.LEFT, left_axis)

# X axis labels
chart.set_axis_labels(Axis.BOTTOM, x_data)

chart.download('fanfou.png')
>_<|| 我手贱!!这个有问题!绝对有问题!!一般般啦,真的很一般般。还不错哦~小表扬一下!GJ!乃就是新世界的神様了,快去拯救世界吧! (1 votes, average: 0.00 out of 5)
Loading...

Comments are closed.

春菜 对话 相声
双击调戏
双击调戏