10000 DOC: fix types in stats docstrings · matplotlib/matplotlib@146a417 · GitHub
[go: up one dir, main page]

Skip to content

Commit 146a417

Browse files
committed
DOC: fix types in stats docstrings
1 parent 32756d5 commit 146a417

11 files changed

+48
-46
lines changed

examples/statistics/boxplot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
mean is the only value not shown by default). The second
1010
figure demonstrates how the styles of the artists of can
1111
be customized. It also demonstrates how to set the limit
12-
if the whiskers to specific percentiles (lower right axes)
12+
of the whiskers to specific percentiles (lower right axes)
1313
"""
1414

1515
import numpy as np

examples/statistics/bxp_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
statistics to the box plot drawer. The first figure demostrates
88
how to remove and add individual components (note that the
99
mean is the only value not shown by default). The second
10-
figure demonstrates how the styles of the artists of can
10+
figure demonstrates how the styles of the artists can
1111
be customized.
1212
"""
1313

examples/statistics/customized_violin_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
The first plot shows the default style by providing only
88
the data. The second plot first limits what matplotlib draws
99
with additional kwargs. Then a simplified representation of
10-
a box plot in drawn on top. Lastly, the styles of arists
10+
a box plot in drawn on top. Lastly, the styles of the artists
1111
of the violins are modified.
1212
"""
1313

@@ -91,9 +91,9 @@ def adjacent_values(vals):
9191
for ax in [ax1, ax2]:
9292
ax.get_xaxis().set_tick_params(direction='out')
9393
ax.xaxis.set_ticks_position('bottom')
94-
ax.set_xticks([x + 1 for x in range(len(lab))])
94+
ax.set_xticks([x for x in np.arange(1, len(lab) + 1)])
9595
ax.set_xticklabels(lab)
96-
ax.set_xlim(0.25, len(lab)+0.75)
96+
ax.set_xlim(0.25, len(lab) + 0.75)
9797
ax.set_xlabel('Sample name')
9898

9999
plt.subplots_adjust(bottom=0.15, wspace=0.05)

examples/statistics/errorbar_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Demo of the errorbar function
44
=============================
55
6-
This exhibits the most basic use of of the error bar method.
7-
In this case, constant values are provided for both the error
8-
in the x- and y-directions.
6+
This exhibits the most basic use of the error bar method.
7+
In this case, constant values are provided for the error
8+
in both the x- and y-directions.
99
"""
1010

1111
import numpy as np

examples/statistics/errorbar_demo_features.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
===================================================
55
66
Errors can be specified as a constant value (as shown in
7-
`errorbar_demo.py`), or as demonstrated in this example, they can be
8-
specified by an N x 1 or 2 x N, where N is the number of data points.
7+
`errorbar_demo.py`). However, this example demonstrates
8+
how they vary by specifying arrays of error values.
99
10-
N x 1:
10+
If the raw `x` and `y` data have length N, there are two options:
11+
12+
Array of shape (N,):
1113
Error varies for each point, but the error values are
1214
symmetric (i.e. the lower and upper values are equal).
1315
14-
2 x N:
16+
Array of shape (2, N):
1517
Error varies for each point, and the lower and upper limits
1618
(in that order) are different (asymmetric case)
1719

examples/statistics/errorbar_limits.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
In matplotlib, errors bars can have "limits". Applying limits to the
77
error bars essentially makes the error unidirectional. Because of that,
88
upper and lower limits can be applied in both the y- and x-directions
9-
via the `uplims`, `lolims`, `xuplims`, and `xlolims` parameters,
10-
respectively. This parameters can be scalar or boolean arrays.
9+
via the ``uplims``, ``lolims``, ``xuplims``, and ``xlolims`` parameters,
10+
respectively. These parameters can be scalar or boolean arrays.
1111
12-
For example, if `xlolims` is `True`, the x-error bars will only extend
13-
from the data towards increasing values. If `uplims` is an array filled
14-
with `False` except for the 3rd and 5th values, all of the y-error bars
15-
will be bi-directional, except the 3rd and 5th bars, which will extend
16-
from the data towards decreasing y-values.
12+
For example, if ``xlolims`` is ``True``, the x-error bars will only
13+
extend from the data towards increasing values. If ``uplims`` is an
14+
array filled with `False` except for the 4th and 7th values, all of the
15+
y-error bars will be bidirectional, except the 4th and 7th bars, which
16+
will extend from the data towards decreasing y-values.
1717
"""
1818

1919
import numpy as np

examples/statistics/errorbars_and_boxes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
In this example, we snazz up a pretty standard error bar plot by adding
77
a rectangle patch defined by the limits of the bars in both the x- and
8-
y- directions. Do this, we have to write our own custom function called
9-
`make_error_boxes`. Close inspection of this function will reveal the
10-
preferred pattern in writting functions for matplotlib:
8+
y- directions. To do this, we have to write our own custom function
9+
called `make_error_boxes`. Close inspection of this function will reveal
10+
the preferred pattern in writing functions for matplotlib:
1111
1212
1. an `Axes` object is passed directly to the function
1313
2. the function operates on the `Axes` methods directly, not through

examples/statistics/histogram_demo_cumulative.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
==========================================================
55
66
This shows how to plot a cumulative, normalized histogram as a
7-
step function as means of visualization the empirical cumulative
7+
step function in order to visualize the empirical cumulative
88
distribution function (CDF) of a sample. We also use the `mlab`
99
module to show the theoretical CDF.
1010
11-
A couple of other options to the `hist` function are demostrated.
12-
Namely, we use the `normed` parameter to normalize the histogram and
11+
A couple of other options to the ``hist`` function are demonstrated.
12+
Namely, we use the ``normed`` parameter to normalize the histogram and
1313
a couple of different options to the `cumulative` parameter. Normalizing
14-
a histogram means that the counts within each bin are scaled such that
15-
the total height of each bin sum up to 1. Since we're showing the
14+
a histogram means that the heights bins are scaled such that
15+
the total area is 1. Since we're showing a normalized and
1616
cumulative histogram, the max value at the end of the series is 1.
17-
The `normed` parameter takes a boolean value.
17+
The ``normed`` parameter takes a boolean value.
1818
19-
The `cumulative` kwarg is a little more nuanced. Like `normed`, you can
20-
pass it True or False, but you can also pass it -1 and that will
21-
reverse the distribution. In engineering, CDFs where `cumulative` is
22-
simply True are sometimes "non-excedance" curves. In other words, you
23-
can look at the y-value to set the probability of excedance. For example
24-
the value of 225 on the x-axis corresponse to about 0.85 on the y-axis,
25-
so there's an 85% chance that an observation in the sames does not
26-
exceed 225.
19+
The ``cumulative`` kwarg is a little more nuanced. Like ``normed``, you
20+
can pass it True or False, but you can also pass it -1 and that will
21+
reverse the distribution. In engineering, CDFs where ``cumulative`` is
22+
simply True are sometimes "non-exceedance" curves. In other words, you
23+
can look at the y-value to set the probability of exceedance. For
24+
example the value of 225 on the x-axis corresponds to about 0.85 on the
25+
y-axis, so there's an 85% chance that an observation in the sample does
26+
not exceed 225.
2727
28-
Conversely, setting, `cumulative` to -1 as is done in the last series
29-
for this example, creates a "excedance" curve.
28+
Conversely, setting, ``cumulative`` to -1 as is done in the last series
29+
for this example, creates a "exceedance" curve.
3030
3131
"""
3232

@@ -39,7 +39,7 @@
3939
mu = 200
4040
sigma = 25
4141
n_bins = 50
42-
x = mu + sigma*np.random.randn(100)
42+
x = np.random.normal(mu, sigma, size=100)
4343

4444
fig, ax = plt.subplots(figsize=(8, 4))
4545

@@ -62,6 +62,6 @@
6262
ax.legend(loc='right')
6363
ax.set_title('Cumulative step histograms')
6464
ax.set_xlabel('Annual rainfall (mm)')
65-
ax.set_ylabel('Likelihood of occurance')
65+
ax.set_ylabel('Likelihood of occurrence')
6666

6767
plt.show()

examples/statistics/histogram_demo_multihist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
ax1.set_title('stacked bar')
3232

3333
ax2.hist(x, n_bins, histtype='step', stacked=True, fill=False)
34-
ax2.set_title('step (unfilled)')
34+
ax2.set_title('stack step (unfilled)')
3535

3636
# Make a multiple-histogram of data-sets with different length.
3737
x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]]

examples/statistics/multiple_histograms_side_by_side.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Demo of how to produce multiple histograms side by side
44
=======================================================
55
6-
This example plots horizonal histograms of different samples along
6+
This example plots horizontal histograms of different samples along
77
a categorical x-axis. Additionally, the histograms are plotted to
88
be symmetrical about their x-position, thus making them very similar
99
to violin plots.

examples/statistics/violinplot_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
Violin plots are similar to histograms and box plots in that they show
77
an abstract representation of the probability distribution of the
88
sample. Rather than showing counts of data points that fall into bins
9-
or order statistics, violin plots use kernal density estimation (KDE) to
10-
compute an emperical distribution of the sample. That computation
9+
or order statistics, violin plots use kernel density estimation (KDE) to
10+
compute an empirical distribution of the sample. That computation
1111
is controlled by several parameters. This example demostrates how to
12-
modify the number of points at the KDE is evaluated (``points``) and
13-
how to modify the band-width of the kde (``bw_method``).
12+
modify the number of points at which the KDE is evaluated (``points``)
13+
and how to modify the band-width of the KDE (``bw_method``).
1414
1515
For more information on violin plots and KDE, the scikit-learn docs
1616
have a great section: http://scikit-learn.org/stable/modules/density.html

0 commit comments

Comments
 (0)
0