首页 > 编程语言 > 详细

python分析上证指数

时间:2020-07-01 19:14:32      阅读:80      评论:0      收藏:0      [点我收藏+]
import xlrd
import xlwt
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from pylab import mpl
pngFile = google_stock_trend.png
mpl.rcParams[font.sans-serif] = [SimHei] # 指定默认字体
mpl.rcParams[axes.unicode_minus] = False # 解决保存图像是负号‘-‘显示为方块的问题,中文显示不乱码
workBook = xlrd.open_workbook(/home/0.xls)
allSheetNames = workBook.sheet_names()
print(allSheetNames)
plt.figure(figsize=(1000,1000))
plt.figure(dpi=300)
# 1.2 按索引号获取sheet的名字(string类型)
sheet1Name = workBook.sheet_names()[0];
print(sheet1Name);
# 2. 获取sheet内容
## 2.1 法1:按索引号获取sheet内容
sheet1_content1 = workBook.sheet_by_index(0); # sheet索引从0开始
## 2.2 法2:按sheet名字获取sheet内容
# sheet1_content2 = workBook.sheet_by_name(‘Sheet1‘);
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(18.5, 10.5)
# 3. sheet的名称,行数,列数
print(sheet1_content1.name,sheet1_content1.nrows,sheet1_content1.ncols);
plt.style.use(seaborn-whitegrid)
x = range(1,7216,1000)
plt.xticks(x,rotation=30)

plt.plot(sheet1_content1.col_values(0),sheet1_content1.col_values(6),label=open,marker=o, linestyle=:, linewidth=1, markersize=3, color=gray)
plt.legend()
plt.title("stock trend")
plt.show(block=True)
fig.savefig(pngFile)

plt.close()

 

python分析上证指数

原文:https://www.cnblogs.com/javage/p/13220700.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!