|
本帖最后由 maxchen_gdyd 于 2020-3-25 23:11 编辑
不知道怎么一页多图2x2那种。搜索了很多还是找不到,现在求助下。
- import numpy as np
- import pandas as pd
- import scipy.stats as scs
- import statsmodels.api as sm
- from pylab import plt
- plt.style.use('ggplot')
- import matplotlib as mpl
- symbols = ['SPY', 'GLD', 'AAPL.O', 'MSFT.O']
- raw = pd.read_csv('tr_eikon_eod_data.csv',
- index_col=0, parse_dates=True)
- data = raw[symbols]
- data = data.dropna()
- log_returns = np.log(data / data.shift(1))
- fig, ax = plt.subplots(2, 2, figsize=(6,4))
- for sym in symbols:
- sm.qqplot(log_returns[sym].dropna(),line='s',ax=ax[sym])
- plt.grid(True)
- plt.xlabel('theoretical quantiles')
- plt.ylabel('sample quantiles')
- plt.title(sym)
- plt.show
复制代码- <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>
复制代码
|
|