Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eded075

Browse filesBrowse files
committed
Rename to Figure.subplots; typo fixes.
1 parent b6c2148 commit eded075
Copy full SHA for eded075

File tree

Expand file treeCollapse file tree

2 files changed

+17
-21
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-21
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+14-18Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ def add_subplot(self, *args, **kwargs):
10021002
self.stale = True
10031003
return a
10041004

1005-
def add_subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
1006-
squeeze=True, subplot_kw=None, gridspec_kw=None):
1005+
def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
1006+
squeeze=True, subplot_kw=None, gridspec_kw=None):
10071007
"""
10081008
Add a set of subplots to this figure.
10091009
@@ -1029,10 +1029,10 @@ def add_subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
10291029
sharey : {"none", "all", "row", "col"} or bool, default: False
10301030
If *False*, or "none", each subplot has its own Y axis.
10311031
1032-
If *True*, or "all", all subplots will share an Y axis, and the x
1032+
If *True*, or "all", all subplots will share an Y axis, and the y
10331033
tick labels on all but the first column of plots will be invisible.
10341034
1035-
If "row", each subplot row will share an Y axis, and the x tick
1035+
If "row", each subplot row will share an Y axis, and the y tick
10361036
labels on all but the first column of plots will be invisible.
10371037
10381038
If "col", each subplot column will share an Y axis.
@@ -1042,16 +1042,15 @@ def add_subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
10421042
array:
10431043
10441044
- if only one subplot is constructed (nrows=ncols=1), the resulting
1045-
single Axes object is returned as a scalar.
1045+
single Axes object is returned as a scalar.
10461046
10471047
- for Nx1 or 1xN subplots, the returned object is a 1-d numpy
1048-
object array of Axes objects are returned as numpy 1-d arrays.
1048+
object array of Axes objects are returned as numpy 1-d arrays.
10491049
10501050
- for NxM subplots with N>1 and M>1 are returned as a 2d array.
10511051
1052-
If *False*, no squeezing at all is done: the returned axes object
1053-
is always a 2-d array of Axes instances, even if it ends up being
1054-
1x1.
1052+
If *False*, no squeezing at all is done: the returned object is
1053+
always a 2-d array of Axes instances, even if it ends up being 1x1.
10551054
10561055
subplot_kw : dict, default: {}
10571056
Dict with keywords passed to the
@@ -1066,7 +1065,7 @@ def add_subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
10661065
Returns
10671066
-------
10681067
ax : single Axes object or array of Axes objects
1069-
The addes axes. The dimensions of the resulting array can be
1068+
The added axes. The dimensions of the resulting array can be
10701069
controlled with the squeeze keyword, see above.
10711070
10721071
See Also
@@ -1114,30 +1113,27 @@ def add_subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
11141113
axarr[row, col] = self.add_subplot(gs[row, col], **subplot_kw)
11151114

11161115
# turn off redundant tick labeling
1117-
if sharex in ["col", "all"] and nrows > 1:
1116+
if sharex in ["col", "all"]:
11181117
# turn off all but the bottom row
11191118
for ax in axarr[:-1, :].flat:
11201119
for label in ax.get_xticklabels():
11211120
label.set_visible(False)
11221121
ax.xaxis.offsetText.set_visible(False)
1123-
1124-
if sharey in ["row", "all"] and ncols > 1:
1122+
if sharey in ["row", "all"]:
11251123
# turn off all but the first column
11261124
for ax in axarr[:, 1:].flat:
11271125
for label in ax.get_yticklabels():
11281126
label.set_visible(False)
11291127
ax.yaxis.offsetText.set_visible(False)
11301128

11311129
if squeeze:
1132-
# Reshape the array to have the final desired dimension (nrow,ncol),
1133-
# though discarding unneeded dimensions that equal 1. If we only have
1134-
# one subplot, just return it instead of a 1-element array.
1130+
# Discarding unneeded dimensions that equal 1. If we only have one
1131+
# subplot, just return it instead of a 1-element array.
11351132
return axarr.item() if axarr.size == 1 else axarr.squeeze()
11361133
else:
1137-
# returned axis array will be always 2-d, even if nrows=ncols=1
1134+
# Returned axis array will be always 2-d, even if nrows=ncols=1.
11381135
return axarr
11391136

1140-
11411137
def clf(self, keep_observers=False):
11421138
"""
11431139
Clear the figure.

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,9 +1132,9 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
11321132
plt.subplots(2, 2, sharex=True, sharey=True)
11331133
"""
11341134
fig = figure(**fig_kw)
1135-
axs = fig.add_subplots(
1136-
nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey, squeeze=squeeze,
1137-
subplot_kw=subplot_kw, gridspec_kw=gridspec_kw)
1135+
axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
1136+
squeeze=squeeze, subplot_kw=subplot_kw,
1137+
gridspec_kw=gridspec_kw)
11381138
return fig, axs
11391139

11401140

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.