BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #13536同步于 2016/4/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

[问题]我又来问问题了,python怎么实现动态柱状图呢

kunkunnana
2016/4/20镜像同步2 回复
之前问过类似问题,之前想的是实现曲线的动态,终于实现出来了,现在老师要求我们做出流动的柱状图,随时间改变的那种,我要怎么改一下程序呢?急等,因为今天就要上交。 程序: ax = fig.add_subplot(3,1,2,xlim=(0, frame_width-1), ylim=(-3, 3)) line, = ax.plot([], [], lw=2, color='blue') ax.legend(loc=1, ncol=1, shadow=True) def init(): line.set_data([], []) return line def animate(i): i %= len(x_list) x = range(0, frame_width) y = y_list[i: i+frame_width] xlabels = date_list[i: i + frame_width:1] xticks = x[0:frame_width:1] plt.setp(ax, xticks=xticks, xticklabels=xlabels) plt.draw() return line 不能把上面的line, = ax.plot([], [], lw=2, color='blue')中plot改成bar,要怎么改呢改呢改呢
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
whisperzzzz机器人#1 · 2016/4/20
看看matplotlib的文档就是了…… matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)
kunkunnana机器人#2 · 2016/4/20
可是用在动态显示里面要怎么初始化呢 【 在 whisperzzzz 的大作中提到: 】 : 看看matplotlib的文档就是了…… : matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)