qqplot line kwarg is broken/docstring is wrong #1462

mwaskom opened this Issue Mar 12, 2014 · 5 comments


None yet

3 participants

mwaskom commented Mar 12, 2014

Not sure which it is, but the qqplot docstring says

line : str {'45', 's', 'r', q'} or None
    Options for the reference line to which the data is compared:

    - '45' - 45-degree line
    - 's' - standardized line, the expected order statistics are scaled
      by the standard deviation of the given sample and have the mean
      added to them
    - 'r' - A regression line is fit
    - 'q' - A line is fit through the quartiles.
    - None - by default no reference line is added to the plot.
    - If True a reference line is drawn on the graph. The default is to
      fit a line via OLS regression.

But when I do

x = np.random.randn(100)
import statsmodels.api as sm
sm.qqplot(x, line=True)

I get:

ValueError                                Traceback (most recent call last)
<ipython-input-60-800869d24bad> in <module>()
      1 x = np.random.randn(100)
----> 2 sm.qqplot(x, line=True)

/Users/mwaskom/anaconda/lib/python2.7/site-packages/statsmodels/graphics/gofplots.pyc in qqplot(data, dist, distargs, a, loc, scale, fit, line, ax)
    475     probplot = ProbPlot(data, dist=dist, distargs=distargs,
    476                          fit=fit, a=a, loc=loc, scale=scale)
--> 477     fig = probplot.qqplot(ax=ax, line=line)
    478     return fig

/Users/mwaskom/anaconda/lib/python2.7/site-packages/statsmodels/graphics/gofplots.pyc in qqplot(self, xlabel, ylabel, line, other, ax)
    306             fig, ax = _do_plot(self.theoretical_quantiles(),
    307                                self.sample_quantiles(),
--> 308                                self.dist, ax=ax, line=line)
    309             if xlabel is None:
    310                 xlabel = "Theoretical Quantiles"

/Users/mwaskom/anaconda/lib/python2.7/site-packages/statsmodels/graphics/gofplots.pyc in _do_plot(x, y, dist, line, ax, fmt)
    706         if line not in ['r','q','45','s']:
    707             msg = "%s option for line not understood" % line
--> 708             raise ValueError(msg)
    710         qqline(ax, line, x=x, y=y, dist=dist)

ValueError: True option for line not understood

(Also the default for line is False, suggesting that True will work).

This is on 0.5.0.


From the description is sounds like True is the same as 'r',
maybe True in docstring is outdated, obsolete option.

BTW: there is currently more refactoring going on in a PR.

mwaskom commented Mar 12, 2014

It's confusing to have the default be False and then accept string codes, seems like a better default would be None or "".


seems like all three, None, False and '' are accepted for no line
docstring says None, signature says False - I agree that None is better

I think True might be left from the very beginning when regression line was the only option.

aside: Since I'm doing robust these days: we should also have an option to use RLM instead of OLS for the regression line.

@jseabold jseabold added this to the 0.5.1 milestone Mar 12, 2014

This is a docs issue and the default kwarg should be fixed. Almost certainly left over from when OLS line was the only option.

@jseabold jseabold added a commit to jseabold/statsmodels that referenced this issue Mar 12, 2014
@jseabold jseabold DOC: Remove defunct argument. Change default kw. Closes #1462. 265d233

Thanks for the report.

@jseabold jseabold closed this in 1138af4 Mar 12, 2014
@PierreBdR PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this issue Sep 2, 2014
@jseabold jseabold DOC: Remove defunct argument. Change default kw. Closes #1462. 6bad295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment