From c289e012406c26c3f2d428d7cf5f07a631fdce6a Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Thu, 10 Dec 2020 17:43:50 -0800 Subject: [PATCH 1/2] FIX: use transform with mplot3d --- lib/mpl_toolkits/mplot3d/axis3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axis3d.py b/lib/mpl_toolkits/mplot3d/axis3d.py index cfd66e8944b6..5fe88350d800 100644 --- a/lib/mpl_toolkits/mplot3d/axis3d.py +++ b/lib/mpl_toolkits/mplot3d/axis3d.py @@ -260,8 +260,8 @@ def draw(self, renderer): lxyz = 0.5 * (edgep1 + edgep2) # A rough estimate; points are ambiguous since 3D plots rotate - ax_scale = self.axes.bbox.size / self.figure.bbox.size - ax_inches = np.multiply(ax_scale, self.figure.get_size_inches()) + reltoinches = self.figure.dpi_scale_trans.inverted() + ax_inches = reltoinches.transform(self.axes.bbox.size) ax_points_estimate = sum(72. * ax_inches) deltas_per_point = 48 / ax_points_estimate default_offset = 21. From 84665b5b81d0cba0cacbddc4f48c5697d890af19 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Thu, 10 Dec 2020 18:08:30 -0800 Subject: [PATCH 2/2] TST: add a test --- lib/mpl_toolkits/tests/test_mplot3d.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index 3bf3d3be5b0d..60436bd6bb93 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -1324,3 +1324,11 @@ def test_scalarmap_update(fig_test, fig_ref): # ref ax_ref = fig_ref.add_subplot(111, projection='3d') sc_ref = ax_ref.scatter(x, y, z, c=c, s=40, cmap='viridis') + + +def test_subfigure_simple(): + # smoketest that subfigures can work... + fig = plt.figure() + sf = fig.subfigures(1, 2) + ax = sf[0].add_subplot(1, 1, 1, projection='3d') + ax = sf[1].add_subplot(1, 1, 1, projection='3d', label='other')