@@ -555,6 +555,7 @@ def gcf():
555
555
else :
556
556
return figure ()
557
557
558
+
558
559
def fignum_exists (num ):
559
560
return _pylab_helpers .Gcf .has_fignum (num ) or num in get_figlabels ()
560
561
@@ -1138,20 +1139,20 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
1138
1139
sharey = "none"
1139
1140
share_values = ["all" , "row" , "col" , "none" ]
1140
1141
if sharex not in share_values :
1141
- # This check was added because it is very easy to type subplots(1, 2, 1)
1142
- # when subplot(1, 2, 1) was intended. In most cases, no error will
1143
- # ever occur, but mysterious behavior will result because what was
1144
- # intended to be the subplot index is instead treated as a bool for
1145
- # sharex.
1142
+ # This check was added because it is very easy to type
1143
+ # `subplots(1, 2, 1)` when ` subplot(1, 2, 1)` was intended.
1144
+ # In most cases, no error will ever occur, but mysterious behavior will
1145
+ # result because what was intended to be the subplot index is instead
1146
+ # treated as a bool for sharex.
1146
1147
if isinstance (sharex , int ):
1147
1148
warnings .warn ("sharex argument to subplots() was an integer."
1148
1149
" Did you intend to use subplot() (without 's')?" )
1149
1150
1150
- raise ValueError ("sharex [%s] must be one of %s" % \
1151
- (sharex , share_values ))
1151
+ raise ValueError ("sharex [%s] must be one of %s" %
1152
+ (sharex , share_values ))
1152
1153
if sharey not in share_values :
1153
- raise ValueError ("sharey [%s] must be one of %s" % \
1154
- (sharey , share_values ))
1154
+ raise ValueError ("sharey [%s] must be one of %s" %
1155
+ (sharey , share_values ))
1155
1156
if subplot_kw is None :
1156
1157
subplot_kw = {}
1157
1158
if gridspec_kw is None :
@@ -1167,10 +1168,6 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
1167
1168
1168
1169
# Create first subplot separately, so we can share it if requested
1169
1170
ax0 = fig .add_subplot (gs [0 , 0 ], ** subplot_kw )
1170
- #if sharex:
1171
- # subplot_kw['sharex'] = ax0
1172
- #if sharey:
1173
- # subplot_kw['sharey'] = ax0
1174
1171
axarr [0 ] = ax0
1175
1172
1176
1173
r , c = np .mgrid [:nrows , :ncols ]
@@ -1203,15 +1200,13 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
1203
1200
1204
1201
# turn off redundant tick labeling
1205
1202
if sharex in ["col" , "all" ] and nrows > 1 :
1206
- #if sharex and nrows>1:
1207
1203
# turn off all but the bottom row
1208
1204
for ax in axarr [:- 1 , :].flat :
1209
1205
for label in ax .get_xticklabels ():
1210
1206
label .set_visible (False )
1211
1207
ax .xaxis .offsetText .set_visible (False )
1212
1208
1213
1209
if sharey in ["row" , "all" ] and ncols > 1 :
1214
- #if sharey and ncols>1:
1215
1210
# turn off all but the first column
1216
1211
for ax in axarr [:, 1 :].flat :
1217
1212
for label in ax .get_yticklabels ():
@@ -1222,8 +1217,8 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
1222
1217
# Reshape the array to have the final desired dimension (nrow,ncol),
1223
1218
# though discarding unneeded dimensions that equal 1. If we only have
1224
1219
# one subplot, just return it instead of a 1-element array.
1225
- if nplots == 1 :
1226
- ret = fig , axarr [0 ,0 ]
1220
+ if nplots == 1 :
1221
+ ret = fig , axarr [0 , 0 ]
1227
1222
else :
1228
1223
ret = fig , axarr .squeeze ()
1229
1224
else :
@@ -1257,10 +1252,12 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, **kwargs):
1257
1252
bbox = a .bbox
1258
1253
byebye = []
1259
1254
for other in fig .axes :
1260
- if other == a : continue
1255
+ if other == a :
1256
+ continue
1261
1257
if bbox .fully_overlaps (other .bbox ):
1262
1258
byebye .append (other )
1263
- for ax in byebye : delaxes (ax )
1259
+ for ax in byebye :
1260
+ delaxes (ax )
1264
1261
1265
1262
return a
1266
1263
0 commit comments