Changing fig size with statsmodel

mlg4080 picture mlg4080 · Feb 14, 2015 · Viewed 8k times · Source

I am trying to make QQ-plots using the statsmodel package. However, the resolution of the figure is so low that I could not possibly use the results in a presentation.

I know that to make networkX graph plot a higher resolution image I can use:

plt.figure( figsize=(N,M) )
networkx.draw(G)

and change the values of N and M to attain desirable results.

However, when I try the same method with a QQ-plot from the statsmodel package, it seems to have no impact on the size of the resulting figure, i.e., when I use

plt.Figure( figsize = (N,M) )
statsmodels.qqplot_2samples(sample1, sample2, line = 'r')

changing M and N have no effect on the figure size. Any ideas on how to fix this (and why this method isn't working)?

Answer

cel picture cel · Feb 14, 2015

You can use mpl.rc_context to temporarily set the default figsize before plotting.

import numpy as np
import matplotlib as mpl
from statsmodels.graphics.gofplots import qqplot_2samples

np.random.seed(10)
sample1 = np.random.rand(10)
sample2 = np.random.rand(10)
n, m = 6, 6

with mpl.rc_context():
    mpl.rc("figure", figsize=(n,m))
    qqplot_2samples(sample1, sample2, line = 'r')

plot