Skip to content

Commit d517420

Browse files
authored
Merge pull request #18041 from meeseeksmachine/auto-backport-of-pr-18038-on-v3.3.x
Backport PR #18038 on branch v3.3.x (FIX: use internal _set_postion, not external)
2 parents 1d0f6ae + 755cb2a commit d517420

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def apply_aspect(self, position=None):
410410
box_aspect = 1
411411
pb = position.frozen()
412412
pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
413-
self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
413+
self._set_position(pb1.anchored(self.get_anchor(), pb), 'active')
414414

415415
@artist.allow_rasterization
416416
def draw(self, renderer):

lib/mpl_toolkits/tests/test_mplot3d.py

+16
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,19 @@ def test_equal_box_aspect():
10081008
ax.set_zlim3d(XYZlim)
10091009
ax.axis('off')
10101010
ax.set_box_aspect((1, 1, 1))
1011+
1012+
1013+
def test_colorbar_pos():
1014+
num_plots = 2
1015+
fig, axs = plt.subplots(1, num_plots, figsize=(4, 5),
1016+
constrained_layout=True,
1017+
subplot_kw={'projection': '3d'})
1018+
for ax in axs:
1019+
p_tri = ax.plot_trisurf(np.random.randn(5), np.random.randn(5),
1020+
np.random.randn(5))
1021+
1022+
cbar = plt.colorbar(p_tri, ax=axs, orientation='horizontal')
1023+
1024+
fig.canvas.draw()
1025+
# check that actually on the bottom
1026+
assert cbar.ax.get_position().extents[1] < 0.2

0 commit comments

Comments
 (0)