一、python numpy + matplotlib 画股票k线图
创新互联主要从事网站设计制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务原州,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792# -- coding: utf-8 -- import requests import numpy as np from matplotlib import pyplot as plt from matplotlib import animation fig = plt.figure(figsize=(8,6), dpi=72,facecolor="white") axes = plt.subplot(111) axes.set_title('Shangzheng') axes.set_xlabel('time') line, = axes.plot([], [], linewidth=1.5, linestyle='-') alldata = [] def dapan(code): url = 'http://hq.sinajs.cn/?list='+code r = requests.get(url) data = r.content[21:-3].decode('gbk').encode('utf8').split(',') alldata.append(data[3]) axes.set_ylim(float(data[5]), float(data[4])) return alldata def init(): line.set_data([], []) return line def animate(i): axes.set_xlim(0, i+10) x = range(i+1) y = dapan('sh000001') line.set_data(x, y) return line anim=animation.FuncAnimation(fig, animate, init_func=init, frames=10000, interval=5000) plt.show()
分享题目:利用pythonnumpy+matplotlib绘制股票k线图的方法-创新互联
分享地址:https://www.cdcxhl.com/article26/dhhscg.html
成都网站建设公司_创新互联,为您提供网站导航、关键词优化、服务器托管、网站建设、外贸建站、网站设计
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联