Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0bbe2c

Browse files
authored
Merge pull request #14423 from anntzer/subplots-doc
Fix docstring of subplots().
2 parents 0edc9af + 22dc398 commit e0bbe2c

File tree

2 files changed

+31
-37
lines changed

2 files changed

+31
-37
lines changed

lib/matplotlib/figure.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,12 +1444,10 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
14441444
Controls sharing of properties among x (`sharex`) or y (`sharey`)
14451445
axes:
14461446
1447-
- True or 'all': x- or y-axis will be shared among all
1448-
subplots.
1449-
- False or 'none': each subplot x- or y-axis will be
1450-
independent.
1451-
- 'row': each subplot row will share an x- or y-axis.
1452-
- 'col': each subplot column will share an x- or y-axis.
1447+
- True or 'all': x- or y-axis will be shared among all subplots.
1448+
- False or 'none': each subplot x- or y-axis will be independent.
1449+
- 'row': each subplot row will share an x- or y-axis.
1450+
- 'col': each subplot column will share an x- or y-axis.
14531451
14541452
When subplots have a shared x-axis along a column, only the x tick
14551453
labels of the bottom subplot are created. Similarly, when subplots
@@ -1461,12 +1459,11 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
14611459
- If True, extra dimensions are squeezed out from the returned
14621460
array of Axes:
14631461
1464-
- if only one subplot is constructed (nrows=ncols=1), the
1465-
resulting single Axes object is returned as a scalar.
1466-
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1467-
object array of Axes objects.
1468-
- for NxM, subplots with N>1 and M>1 are returned
1469-
as a 2D array.
1462+
- if only one subplot is constructed (nrows=ncols=1), the
1463+
resulting single Axes object is returned as a scalar.
1464+
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1465+
object array of Axes objects.
1466+
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
14701467
14711468
- If False, no squeezing at all is done: the returned Axes object
14721469
is always a 2D array containing Axes instances, even if it ends
@@ -1501,19 +1498,18 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
15011498
# Create a figure
15021499
plt.figure()
15031500
1504-
# Creates a subplot
1501+
# Create a subplot
15051502
ax = fig.subplots()
15061503
ax.plot(x, y)
15071504
ax.set_title('Simple plot')
15081505
1509-
# Creates two subplots and unpacks the output array immediately
1506+
# Create two subplots and unpack the output array immediately
15101507
ax1, ax2 = fig.subplots(1, 2, sharey=True)
15111508
ax1.plot(x, y)
15121509
ax1.set_title('Sharing Y axis')
15131510
ax2.scatter(x, y)
15141511
1515-
# Creates four polar axes, and accesses them through the
1516-
# returned array
1512+
# Create four polar axes and access them through the returned array
15171513
axes = fig.subplots(2, 2, subplot_kw=dict(polar=True))
15181514
axes[0, 0].plot(x, y)
15191515
axes[1, 1].scatter(x, y)
@@ -1530,12 +1526,12 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
15301526
# Note that this is the same as
15311527
fig.subplots(2, 2, sharex=True, sharey=True)
15321528
1533-
See Also
1534-
--------
1535-
.pyplot.subplots
1536-
.Figure.add_subplot
1537-
.pyplot.subplot
1538-
"""
1529+
See Also
1530+
--------
1531+
.pyplot.subplots
1532+
.Figure.add_subplot
1533+
.pyplot.subplot
1534+
"""
15391535

15401536
if isinstance(sharex, bool):
15411537
sharex = "all" if sharex else "none"

lib/matplotlib/pyplot.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,12 +1056,10 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10561056
Controls sharing of properties among x (`sharex`) or y (`sharey`)
10571057
axes:
10581058
1059-
- True or 'all': x- or y-axis will be shared among all
1060-
subplots.
1061-
- False or 'none': each subplot x- or y-axis will be
1062-
independent.
1063-
- 'row': each subplot row will share an x- or y-axis.
1064-
- 'col': each subplot column will share an x- or y-axis.
1059+
- True or 'all': x- or y-axis will be shared among all subplots.
1060+
- False or 'none': each subplot x- or y-axis will be independent.
1061+
- 'row': each subplot row will share an x- or y-axis.
1062+
- 'col': each subplot column will share an x- or y-axis.
10651063
10661064
When subplots have a shared x-axis along a column, only the x tick
10671065
labels of the bottom subplot are created. Similarly, when subplots
@@ -1073,11 +1071,11 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10731071
- If True, extra dimensions are squeezed out from the returned
10741072
array of `~matplotlib.axes.Axes`:
10751073
1076-
- if only one subplot is constructed (nrows=ncols=1), the
1077-
resulting single Axes object is returned as a scalar.
1078-
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1079-
object array of Axes objects.
1080-
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
1074+
- if only one subplot is constructed (nrows=ncols=1), the
1075+
resulting single Axes object is returned as a scalar.
1076+
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
1077+
object array of Axes objects.
1078+
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
10811079
10821080
- If False, no squeezing at all is done: the returned Axes object is
10831081
always a 2D array containing Axes instances, even if it ends up
@@ -1133,18 +1131,18 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
11331131
x = np.linspace(0, 2*np.pi, 400)
11341132
y = np.sin(x**2)
11351133
1136-
# Creates just a figure and only one subplot
1134+
# Create just a figure and only one subplot
11371135
fig, ax = plt.subplots()
11381136
ax.plot(x, y)
11391137
ax.set_title('Simple plot')
11401138
1141-
# Creates two subplots and unpacks the output array immediately
1139+
# Create two subplots and unpack the output array immediately
11421140
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
11431141
ax1.plot(x, y)
11441142
ax1.set_title('Sharing Y axis')
11451143
ax2.scatter(x, y)
11461144
1147-
# Creates four polar axes, and accesses them through the returned array
1145+
# Create four polar axes and access them through the returned array
11481146
fig, axs = plt.subplots(2, 2, subplot_kw=dict(polar=True))
11491147
axs[0, 0].plot(x, y)
11501148
axs[1, 1].scatter(x, y)
@@ -1161,7 +1159,7 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
11611159
# Note that this is the same as
11621160
plt.subplots(2, 2, sharex=True, sharey=True)
11631161
1164-
# Creates figure number 10 with a single subplot
1162+
# Create figure number 10 with a single subplot
11651163
# and clears it if it already exists.
11661164
fig, ax = plt.subplots(num=10, clear=True)
11671165

0 commit comments

Comments
 (0)