8000 First pass; seems to work. More testing needed · matplotlib/matplotlib@c68a411 · GitHub
[go: up one dir, main page]

Skip to content

Commit c68a411

Browse files
committed
First pass; seems to work. More testing needed
1 parent 89857c7 commit c68a411

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

lib/matplotlib/colorbar.py

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11571157

11581158

11591159
@docstring.Substitution(make_axes_kw_doc)
1160-
def make_axes_gridspec(parents, **kw):
1160+
def make_axes_gridspec(parent, **kw):
11611161
'''
11621162
Resize and reposition a parent axes, and return a child axes
11631163
suitable for a colorbar. This function is similar to
@@ -1204,35 +1204,13 @@ def make_axes_gridspec(parents, **kw):
12041204
pad_s = (1. - shrink) * 0.5
12051205
wh_ratios = [pad_s, shrink, pad_s]
12061206

1207-
# make parents a 1-d ndarray if its not already...
1208-
parents = np.atleast_1d(parents).ravel()
1209-
# get the appropriate subplot spec. Loop through the parents.
1210-
gs0 = parents[0].get_subplotspec().get_gridspec()
1211-
minind = 10000
1212-
maxind = -10000
1213-
for parent in parents:
1214-
gs = parent.get_subplotspec().get_gridspec()
1215-
if gs == gs0:
1216-
ss = parent.get_subplotspec().get_geometry()
1217-
if ss[2]<minind:
1218-
minind = ss[2]
1219-
if ss[3]>maxind:
1220-
maxind = ss[3]
1221-
else:
1222-
pass
1223-
print(minind)
1224-
print(maxind)
1225-
subspec = gridspec.SubplotSpec(gs0,minind,maxind)
1226-
print(subspec)
1227-
print(subspec.get_geometry())
1228-
12291207
gs_from_subplotspec = gridspec.GridSpecFromSubplotSpec
12301208
if orientation == 'vertical':
12311209
pad = kw.pop('pad', 0.05)
12321210
wh_space = 2 * pad / (1 - pad)
12331211

12341212
gs = gs_from_subplotspec(1, 2,
1235-
subplot_spec=subspec,
1213+
subplot_spec=parent.get_subplotspec(),
12361214
wspace=wh_space,
12371215
width_ratios=[x1 - pad, fraction]
12381216
)
@@ -1242,8 +1220,6 @@ def make_axes_gridspec(parents, **kw):
12421220
hspace=0.,
12431221
height_ratios=wh_ratios,
12441222
)
1245-
print(gs)
1246-
print(gs2)
12471223

12481224
anchor = (0.0, 0.5)
12491225
panchor = (1.0, 0.5)
@@ -1252,7 +1228,7 @@ def make_axes_gridspec(parents, **kw):
12521228
wh_space = 2 * pad / (1 - pad)
12531229

12541230
gs = gs_from_subplotspec(2, 1,
1255-
subplot_spec=subspec,
1231+
subplot_spec=parent.get_subplotspec(),
12561232
hspace=wh_space,
12571233
height_ratios=[x1 - pad, fraction]
12581234
)
@@ -1267,13 +1243,12 @@ def make_axes_gridspec(parents, **kw):
12671243
anchor = (0.5, 1.0)
12681244
panchor = (0.5, 0.0)
12691245

1270-
for parent in parents:
1271-
parent.set_subplotspec(gs[0])
1272-
parent.update_params()
1273-
parent.set_position(parent.figbox)
1274-
parent.set_anchor(panchor)
1246+
parent.set_subplotspec(gs[0])
1247+
parent.update_params()
1248+
parent.set_position(parent.figbox)
1249+
parent.set_anchor(panchor)
12751250

1276-
fig = parents[0].get_figure()
1251+
fig = parent.get_figure()
12771252
cax = fig.add_subplot(gs2[1])
12781253
cax.set_aspect(aspect, anchor=anchor, adjustable='box')
12791254
return cax, kw

0 commit comments

Comments
 (0)
0