Python Forum
Python: how to do multiple qqplot in statsmodel
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python: how to do multiple qqplot in statsmodel
#1
Hi,I'm new to python. At moment, I'm trying to do qqplot in statsmodels, with price data from dozens of stocks. apparently I'm on restricted group not allowed for attachments.

I want to plot multiple qqplots on one page with 2x2 style, but cannot get the plots correct. Having done much research, I think if it would be much helpful if people could give me some hints or tell me where the problem is.

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


raw = pd.read_csv('tr_eikon_eod_data.csv',
                  index_col=0, parse_dates=True)#read in data
symbols = ['SPY', 'GLD', 'AAPL.O', 'MSFT.O']#name for each stock.
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['SPY'].dropna(),line='s',ax=ax[sym])

plt.grid(True)
plt.xlabel('theoretical quantiles')
plt.ylabel('sample quantiles')
plt.title(sym)

plt.show   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,520 Nov-25-2023, 05:31 AM
Last Post: Iqratech

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020