Python: how to do multiple qqplot in statsmodel

I’m new to python. At moment, I’m trying to do qqplot in statsmodels, with data from a csv file. No idea on how to upload data file, so I capture part of it as picture.

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)
symbols = ['SPY', 'GLD', 'AAPL.O', 'MSFT.O']
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   

Hi

This is a subroutine I wrote today that will help you sort it out…

def qqplot(data,dist_name, quadrant, fig, label):
ax = fig.add_subplot(2, 2, quadrant)
LilPlot = sm.graphics.qqplot(data,dist_name,fit=True, ax=ax)
ax.set_xlim(-4, 4)
ax.set_ylim(-4, 4)
return quadrant, LilPlot

fig = plt.figure(figsize=(10, 7.5), dpi=80)
quadrant = 1

for index, row in MyDataFrame.iterrows():
qqplot(myObservedData, row[0], quadrant, fig, myLabel)
quadrant = quadrant + 1

plt.show()