Skip to content

Commit 5ede27a

Browse files
committed
let user specify any scipy dist in viz.probplot
1 parent b4d24a2 commit 5ede27a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

probscale/viz.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from . import validate
66

77

8-
def probplot(data, ax=None, color=None, label=None, axtype='prob',
9-
probax='x', otherscale='linear', xlabel=None, ylabel=None,
10-
bestfit=False, return_results=False, scatter_kws=None,
11-
line_kws=None, pp_kws=None):
8+
def probplot(data, ax=None, axtype='prob', dist=None, probax='x',
9+
color=None, label=None, otherscale='linear', xlabel=None,
10+
ylabel=None, bestfit=False, return_results=False,
11+
scatter_kws=None, line_kws=None, pp_kws=None):
1212
""" Probability, percentile, and quantile plots.
1313
1414
Parameters
@@ -18,17 +18,20 @@ def probplot(data, ax=None, color=None, label=None, axtype='prob',
1818
ax : matplotlib axes, optional
1919
The Axes on which to plot. If one is not provided, a new Axes
2020
will be created.
21+
axtype : string (default = 'prob')
22+
Type of plot to be created. Options are:
23+
- 'prob': probabilty plot
24+
- 'pp': percentile plot
25+
- 'qq': quantile plot
26+
dist : scipy distribution, optional
27+
A distribtion to compute the scale's tick positions. If not
28+
specified, a normal distribution will be used.
2129
color : valid matplotlib color specification, optional
2230
If provided, this value will be added to the ``scatter_kws``
2331
and ``line_kws`` dictionary under the "color" key.
2432
label : string, optional
2533
If provided, this legend label is applied to the scatter series
2634
of the probability plot.
27-
axtype : string (default = 'prob')
28-
Type of plot to be created. Options are:
29-
- 'prob': probabilty plot
30-
- 'pp': percentile plot
31-
- 'qq': quantile plot
3235
probax : string, optional (default = 'x')
3336
The axis ('x' or 'y') that will serve as the probability (or
3437
quantile) axis.
@@ -69,6 +72,9 @@ def probplot(data, ax=None, color=None, label=None, axtype='prob',
6972
7073
"""
7174

75+
if dist is None:
76+
dist = _minimal_norm
77+
7278
# check input values
7379
fig, ax = validate.axes_object(ax)
7480
probax = validate.axis_name(probax, 'x')
@@ -102,7 +108,7 @@ def probplot(data, ax=None, color=None, label=None, axtype='prob',
102108
if probax == 'x':
103109
x, y = probvals, datavals
104110
if axtype == 'prob':
105-
ax.set_xscale('prob')
111+
ax.set_xscale('prob', dist=dist)
106112
fitprobs = 'x'
107113
else:
108114
fitprobs = None
@@ -116,7 +122,7 @@ def probplot(data, ax=None, color=None, label=None, axtype='prob',
116122
elif probax == 'y':
117123
y, x = probvals, datavals
118124
if axtype == 'prob':
119-
ax.set_yscale('prob')
125+
ax.set_yscale('prob', dist=dist)
120126
fitprobs = 'y'
121127
else:
122128
fitprobs = None
@@ -141,7 +147,7 @@ def probplot(data, ax=None, color=None, label=None, axtype='prob',
141147

142148
# maybe do a best-fit and plot
143149
if bestfit:
144-
xhat, yhat, modelres = _fit_line(x, y, fitprobs=fitprobs, fitlogs=fitlogs)
150+
xhat, yhat, modelres = _fit_line(x, y, fitprobs=fitprobs, fitlogs=fitlogs, dist=dist)
145151
ax.plot(xhat, yhat, **line_kws)
146152
else:
147153
xhat, yhat, modelres = (None, None, None)

0 commit comments

Comments
 (0)