Repository: statsmodels/statsmodels

Issue:
qqplot line kwarg is broken/docstring is wrong
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

``` python
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
    479 

/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)
    709 
    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`.



Discussion:
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.

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.

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


Resolving patch:
diff --git a/statsmodels/graphics/gofplots.py b/statsmodels/graphics/gofplots.py
--- a/statsmodels/graphics/gofplots.py
+++ b/statsmodels/graphics/gofplots.py
@@ -210,8 +210,7 @@ def ppplot(self, xlabel=None, ylabel=None, line=None, other=None,
             - '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.
+
         other : `ProbPlot` instance, array-like, or None, optional
             If provided, the sample quantiles of this `ProbPlot` instance are
             plotted against the sample quantiles of the `other` `ProbPlot`
@@ -283,8 +282,7 @@ def qqplot(self, xlabel=None, ylabel=None, line=None, other=None,
             - '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.
+
         other : `ProbPlot` instance, array-like, or None, optional
             If provided, the sample quantiles of this `ProbPlot` instance are
             plotted against the sample quantiles of the `other` `ProbPlot`
@@ -357,8 +355,7 @@ def probplot(self, xlabel=None, ylabel=None, line=None,
             - '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.
+
         exceed : boolean, optional
 
              - If False (default) the raw sample quantiles are plotted against
@@ -405,7 +402,7 @@ def probplot(self, xlabel=None, ylabel=None, line=None,
         return fig
 
 def qqplot(data, dist=stats.norm, distargs=(), a=0, loc=0, scale=1, fit=False,
-           line=False, ax=None):
+           line=None, ax=None):
     """
     Q-Q plot of the quantiles of x versus the quantiles/ppf of a distribution.
 
@@ -446,8 +443,6 @@ def qqplot(data, dist=stats.norm, distargs=(), a=0, loc=0, scale=1, fit=False,
         - '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.
 
     ax : Matplotlib AxesSubplot instance, optional
         If given, this subplot is used to plot in instead of a new figure being
@@ -532,8 +527,6 @@ def qqplot_2samples(data1, data2, xlabel=None, ylabel=None, line=None, ax=None):
         - '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.
 
     ax : Matplotlib AxesSubplot instance, optional
         If given, this subplot is used to plot in instead of a new figure being


Test patch: