8000 DOC: cleanup pairwise · matplotlib/matplotlib@c00efe5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c00efe5

Browse files
committed
DOC: cleanup pairwise
1 parent 98f2806 commit c00efe5

File tree

1 file changed

+38
-36
lines changed
Collapse file tree

1 file changed

+38
-36
lines changed

galleries/users_explain/plotting/pairwise.py

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# %%
3636
# By default, `~.Axes.plot` joins data points with a solid straight line, as
3737
# shown in the jagged nature of the plot above. We can style that line,
38-
# with dashes or plot the data with symbols, or both, as below.
38+
# with dashes, plot the data with symbols, or both styles, as demonstrated below.
3939

4040
fig, axs = plt.subplots(3, 1, sharex=True)
4141
ax = axs[0]
@@ -48,12 +48,12 @@
4848
ax.set_xlabel('x')
4949

5050
# %%
51-
# It is possible to plot multiple datasets at once against one ``x`` array
52-
# if the shape of ``Y`` matches. Here note that ``Y`` has shape ``(30,3)``
53-
# so the length of each column is the same as the length of ``x``.
54-
# Each column of data in ``Y`` gets a different color following the
51+
# Multiple datasets can be plotted simultaneously against a single ``x`` array
52+
# if the shape of ``Y`` is compatible. In this example, ``Y`` has the shape ``(30, 3)``,
53+
# meaning each column has the same length as ``x``.
54+
# Each column in ``Y`` is assigned a different color according to the
5555
# default :ref:`color cycle <color_cycle>`. A legend for each column in
56-
# ``Y`` is created by passing a **label** with a list of column names:
56+
# ``Y`` is generated by providing a **label** with a list of column names:
5757

5858
Y = np.arange(30*3).reshape(3, 30).T
5959
fig, ax = plt.subplots(figsize=(5, 3))
@@ -63,7 +63,7 @@
6363

6464
# %%
6565
# fill_between, fill_betweenx, and stackplot
66-
# ------------------------------------------
66+
# -----------------------------------------
6767
#
6868
# The `~.Axes.fill_between` method is useful to indicate a confidence interval
6969
# around a line plot. In this example, the confidence interval is imagined to
@@ -153,12 +153,12 @@
153153

154154
# %%
155155
#
156-
# `~.Axes.errorbar` inherits from `~.Axes.plot`, so the same format strings can
157-
# be used to control the marker's appearance. Errorbar appearance is controlled
158-
# by keyword arguments such as *ecolor* for the color of the error bar lines,
159-
# **capsize** for the length of the error bar caps, and *elinewidth* for the
160-
# thickness of the error bar lines. The error bars can also be asymmetric if
161-
# *yerr* or *xerr* are 2D arrays.
156+
# `~.Axes.errorbar` inherits from `~.Axes.plot`, allowing the use of the same
157+
# format to control the marker's appearance. The appearance of error bars is
158+
# controlled by keyword arguments such as *ecolor* for the color of the error
159+
# bar lines, **capsize** for the length of the error bar caps, and *elinewidth*
160+
# for the thickness of the error bar lines. Error bars can also be asymmetric
161+
# if *yerr* or *xerr* are provided as 2D arrays.
162162

163163
fig, ax = plt.subplots()
164164
ax.errorbar(x, y, yerr=[erry, 2*erry], xerr=[errx, 2*errx], fmt='o',
@@ -171,13 +171,13 @@
171171
# scatter
172172
# -------
173173
#
174-
# The `~.Axes.scatter` method is similar to `~.Axes.plot` in that it will plot two
175-
# arrays of data against each other, but differs in that
174+
# The `~.Axes.scatter` method is similar to `~.Axes.plot` in that it plots two
175+
# arrays of data against each other, but differs in the following ways:
176176
#
177-
# * there is no option to connect markers with lines
178-
# * the size and color of markers can vary according to the value of other data arrays.
177+
# * there is no option to connect markers with lines,
178+
# * the size and color of markers can vary according to the values of other data arrays.
179179
#
180-
# This example shows how to plot a scatter plot with varying point sizes using
180+
# This example demonstrates how to create a scatter plot with varying point sizes using
181181
# the *s* keyword and and colors using the *c* keyword.
182182

183183
y = np.sin(x)
@@ -194,9 +194,10 @@
194194
fig.colorbar(scatter, label="Value of sin(x)")
195195

196196
#######################################################################################
197-
# We can change the marker (see :mod:`matplotlib.markers` for a full list), but each
198-
# call to scatter can only accept one *marker*. If it is desired to code data by
199-
# marker shape, then make multiple calls to `~.Axes.scatter`
197+
# The marker style can be changed (see :mod:`matplotlib.markers` for a full
198+
# list), but each call to `~.Axes.scatter` can only accept one *marker* type.
199+
# To code data by different marker shapes, make multiple calls to
200+
# `~.Axes.scatter`.
200201

201202
y2 = np.cos(x)
202203
colors2 = y2
@@ -226,7 +227,7 @@
226227
# ---------------------
227228
#
228229
# `~.Axes.bar`, `~.Axes.stairs`, and `~.Axes.stem` are useful for plotting data
229-
# that deviates from a zero or mean value, and are often used to plot
230+
# that deviates from a zero or mean value. These methods are often used to plot
230231
# histograms.
231232

232233
x = x[::2]
@@ -246,9 +247,9 @@
246247
ax.set_ylabel('sin(x)')
247248

248249
# %%
249-
# `~.Axes.bar` does not automatically calculate a *width* for the bars, so you
250-
# typically have to calculate it yourself to get the correct spacing. *width*
251-
# can also be an array with the same length as *x* to specify the width of each
250+
# `~.Axes.bar` does not automatically calculate the *width* of the bars, so it
251+
# typically needs to be calculated manually to achieve the correct spacing. The *width*
252+
# can also be specified as an array with the same length as *x* to set the width of each
252253
# bar individually.
253254

254255
fig, ax = plt.subplots()
@@ -262,10 +263,10 @@
262263
#
263264
# `~.Axes.step` and `~.Axes.stairs` are similar to `~.Axes.plot` but plot a
264265
# step between each data point. They accept differently shaped data depending
265-
# on your use case.
266+
# on the use case.
266267
#
267-
# `~.Axes.step` is useful for plotting steps, and accepts the same data shape
268-
# as `~.Axes.plot`.
268+
# `~.Axes.step` particularly useful as it accepts the same data shape as
269+
# `~.Axes.plot`.
269270

270271
fig, ax = plt.subplots()
271272

@@ -275,11 +276,12 @@
275276
ax.set_title('step')
276277

277278
# %%
278-
# Note that we can center the steps on the data in different ways
279-
# using the **where** keyword. The default is **where='pre'** which
280-
# mea C034 ns the step extends to the left of the data point. **where='mid'**
281-
# means the step extends half way to the next data point, and **where='post'**
282-
# means the step extends to the right of the data point:
279+
280+
# The steps can be centered on the data in different ways using the **where**
281+
# keyword. The default is **where='pre'**, which means the step extends to the
282+
# left of the data point. **where='mid'** means the step extends halfway to the
283+
# next data point, and **where='post'** means the step extends to the right of
284+
# the data point:
283285

284286
fig, axs = plt.subplots(3, 1, sharex=True, sharey=True, figsize=(4.5, 5))
285287

@@ -295,9 +297,9 @@
295297

296298
# %%
297299
#
298-
# `~.Axes.stairs` is useful for plotting histograms, and specifies the edges of steps
299-
# rather than the centers. This is particularly useful for plotting histograms, and can
300-
# be used with the result from `~numpy.histogram`.
300+
# `~.Axes.stairs` is useful for plotting histograms, and specifies the edges of
301+
# steps rather than the centers, so can directly be used with the result from
302+
# `~numpy.histogram`.
301303

302304
data = rng.normal(size=1000)
303305
hist, bin_edges = np.histogram(data, bins=np.arange(-4, 4, 0.2), density=True)

0 commit comments

Comments
 (0)
0