Skip to content

Commit a5ac5a5

Browse files
committed
DOC: Fixup the percentile methods plot
1 parent 85f3dda commit a5ac5a5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

numpy/lib/function_base.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,7 +4084,7 @@ def percentile(a,
40844084
array([7., 2.])
40854085
>>> assert not np.all(a == b)
40864086
4087-
The different types of interpolation can be visualized graphically:
4087+
The different methods can be visualized graphically:
40884088
40894089
.. plot::
40904090
@@ -4094,20 +4094,25 @@ def percentile(a,
40944094
p = np.linspace(0, 100, 6001)
40954095
ax = plt.gca()
40964096
lines = [
4097-
('linear', None),
4098-
('higher', '--'),
4099-
('lower', '--'),
4100-
('nearest', '-.'),
4101-
('midpoint', '-.'),
4102-
]
4103-
for interpolation, style in lines:
4097+
('linear', '-', 'C0'),
4098+
('inverted_cdf', ':', 'C1'),
4099+
# Almost the same as `inverted_cdf`:
4100+
('averaged_inverted_cdf', '-.', 'C1'),
4101+
('closest_observation', ':', 'C2'),
4102+
('interpolated_inverted_cdf', '--', 'C1'),
4103+
('hazen', '--', 'C3'),
4104+
('weibull', '-.', 'C4'),
4105+
('median_unbiased', '--', 'C5'),
4106+
('normal_unbiased', '-.', 'C6'),
4107+
]
4108+
for method, style, color in lines:
41044109
ax.plot(
4105-
p, np.percentile(a, p, interpolation=interpolation),
4106-
label=interpolation, linestyle=style)
4110+
p, np.percentile(a, p, method=method),
4111+
label=method, linestyle=style, color=color)
41074112
ax.set(
4108-
title='Result for the data: ' + str(a),
4113+
title='Percentiles for different methods and data: ' + str(a),
41094114
xlabel='Percentile',
4110-
ylabel='List item returned',
4115+
ylabel='Estimated percentile value',
41114116
yticks=a)
41124117
ax.legend()
41134118
plt.show()
@@ -4347,6 +4352,8 @@ def quantile(a,
43474352
array([7., 2.])
43484353
>>> assert not np.all(a == b)
43494354
4355+
See also `numpy.percentile` for a visualization of most methods.
4356+
43504357
References
43514358
----------
43524359
.. [1] R. J. Hyndman and Y. Fan,

0 commit comments

Comments
 (0)