@@ -1166,7 +1166,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
1166
1166
1167
1167
1168
1168
@docstring .Substitution (make_axes_kw_doc )
1169
- def make_axes_gridspec (parent , ** kw ):
1169
+ def make_axes_gridspec (parents , ** kw ):
1170
1170
'''
1171
1171
Resize and reposition a parent axes, and return a child axes
1172
1172
suitable for a colorbar. This function is similar to
@@ -1213,13 +1213,35 @@ def make_axes_gridspec(parent, **kw):
1213
1213
pad_s = (1. - shrink ) * 0.5
1214
1214
wh_ratios = [pad_s , shrink , pad_s ]
1215
1215
1216
+ # make parents a 1-d ndarray if its not already...
1217
+ parents = np .atleast_1d (parents ).ravel ()
1218
+ # get the appropriate subplot spec. Loop through the parents.
1219
+ gs0 = parents [0 ].get_subplotspec ().get_gridspec ()
1220
+ minind = 10000
1221
+ maxind = - 10000
1222
+ for parent in parents :
1223
+ gs = parent .get_subplotspec ().get_gridspec ()
1224
+ if gs == gs0 :
1225
+ ss = parent .get_subplotspec ().get_geometry ()
1226
+ if ss [2 ]< minind :
1227
+ minind = ss [2 ]
1228
+ if ss [3 ]> maxind :
1229
+ maxind = ss [3 ]
1230
+ else :
1231
+ pass
1232
+ print (minind )
1233
+ print (maxind )
10000
code>
1234
+ subspec = gridspec .SubplotSpec (gs0 ,minind ,maxind )
1235
+ print (subspec )
1236
+ print (subspec .get_geometry ())
1237
+
1216
1238
gs_from_subplotspec = gridspec .GridSpecFromSubplotSpec
1217
1239
if orientation == 'vertical' :
1218
1240
pad = kw .pop ('pad' , 0.05 )
1219
1241
wh_space = 2 * pad / (1 - pad )
1220
1242
1221
1243
gs = gs_from_subplotspec (1 , 2 ,
1222
- subplot_spec = parent . get_subplotspec () ,
1244
+ subplot_spec = subspec ,
1223
1245
wspace = wh_space ,
1224
1246
width_ratios = [x1 - pad , fraction ]
1225
1247
)
@@ -1229,6 +1251,8 @@ def make_axes_gridspec(parent, **kw):
1229
1251
hspace = 0. ,
1230
1252
height_ratios = wh_ratios ,
1231
1253
)
1254
+ print (gs )
1255
+ print (gs2 )
1232
1256
1233
1257
anchor = (0.0 , 0.5 )
1234
1258
panchor = (1.0 , 0.5 )
@@ -1237,7 +1261,7 @@ def make_axes_gridspec(parent, **kw):
1237
1261
wh_space = 2 * pad / (1 - pad )
1238
1262
1239
1263
gs = gs_from_subplotspec (2 , 1 ,
1240
- subplot_spec = parent . get_subplotspec () ,
1264
+ subplot_spec = subspec ,
1241
1265
hspace = wh_space ,
1242
1266
height_ratios = [x1 - pad , fraction ]
1243
1267
)
@@ -1252,12 +1276,13 @@ def make_axes_gridspec(parent, **kw):
1252
1276
anchor = (0.5 , 1.0 )
1253
1277
panchor = (0.5 , 0.0 )
1254
1278
1255
- parent .set_subplotspec (gs [0 ])
1256
- parent .update_params ()
1257
- parent .set_position (parent .figbox )
1258
- parent .set_anchor (panchor )
1279
+ for parent in parents :
1280
+ parent .set_subplotspec (gs [0 ])
1281
+ parent .update_params ()
1282
+ parent .set_position (parent .figbox )
1283
+ parent .set_anchor (panchor )
1259
1284
1260
- fig = parent .get_figure ()
1285
+ fig = parents [ 0 ] .get_figure ()
1261
1286
cax = fig .add_subplot (gs2 [1 ])
1262
1287
cax .set_aspect (aspect , anchor = anchor , adjustable = 'box' )
1263
1288
return cax , kw
0 commit comments