找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2437|回复: 0

[求助] python qqplot 一页多图

回帖奖励 1 点威望 回复本帖可获得 1 点威望奖励! 每人限 1 次

0

主题

0

帖子

0

积分

贫民

积分
0
maxchen_gdyd 发表于 2020-3-25 21:54:51 | 显示全部楼层 |阅读模式
本帖最后由 maxchen_gdyd 于 2020-3-25 23:11 编辑

不知道怎么一页多图2x2那种。搜索了很多还是找不到,现在求助下。
  1. import numpy as np
  2.     import pandas as pd
  3.     import scipy.stats as scs
  4.     import statsmodels.api as sm
  5.     from pylab import plt
  6.     plt.style.use('ggplot')
  7.     import matplotlib as mpl

  8.     symbols = ['SPY', 'GLD', 'AAPL.O', 'MSFT.O']
  9.     raw = pd.read_csv('tr_eikon_eod_data.csv',
  10.                     index_col=0, parse_dates=True)
  11.     data = raw[symbols]
  12.     data = data.dropna()
  13.     log_returns = np.log(data / data.shift(1))


  14.     fig, ax = plt.subplots(2, 2, figsize=(6,4))
  15.        for sym in symbols:
  16.           sm.qqplot(log_returns[sym].dropna(),line='s',ax=ax[sym])


  17.     plt.grid(True)
  18.     plt.xlabel('theoretical quantiles')
  19.     plt.ylabel('sample quantiles')
  20.     plt.title(sym)

  21.     plt.show   
复制代码
  1. <pre class="lang-py prettyprint prettyprinted" style="margin: 0px 0px 1em; padding: 12px 8px; border: 0px; border-image: none; line-height: inherit; font-stretch: inherit;" initial;"="" initial;="" 0px;="" 2;="" none;="" left;="" normal;="" 41);="" 39,="" rgb(36,="" block;="" 3px;="" var(--black-050);="" auto;="" 600px;="" inherit;="" baseline;="" 13px;="" sans-serif;="" monospace,="" new",="" "courier="" mono",="" sans="" vera="" "bitstream="" "dejavu="" "liberation="" c**ole",="" lucida=""><code style="margin: 0px; padding: 0px; border: 0px; border-image: none; line-height: inherit; font-variant: inherit; font-stretch: inherit;" var(--black-050);="" inherit;="" baseline;="" 13px;="" sans-serif;="" monospace,="" new",="" "courier="" mono",="" sans="" vera="" "bitstream="" "dejavu="" "liberation="" c**ole",="" lucida="" inherit;"=""><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; border-image: none; color:  var(--blue-800); line-height: inherit; font-family: inherit; font-size: 13px; font-variant: inherit; box-sizing: inherit; font-stretch: inherit;"></span></code></pre>
复制代码


tr_eikon_eod_data.csv

186.45 KB, 下载次数: 1

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表