zoukankan      html  css  js  c++  java
  • python分析上证指数

    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()
    ...
  • 相关阅读:
    协方差矩阵
    SLAM中的关键帧是什么?有什么用?如何选择关键帧?
    EKF算法与非线性优化算法的比较
    LC217 存在重复元素
    LC42 接雨水
    LC20 有效的括号
    LC3 无重复最长子串
    LC4 寻找两个有序数组的中位数
    ubuntu16.04下安装g2o
    小米 各版本手机系统包 线刷包 卡刷包
  • 原文地址:https://www.cnblogs.com/javage/p/13220700.html
Copyright © 2011-2022 走看看