From 4313f7ca6c8d59e8454b1d7253f582b8e4e0aa3f Mon Sep 17 00:00:00 2001 From: Zexi Date: Thu, 1 Jul 2021 02:58:35 +0800 Subject: [PATCH 1/2] Fix xs length The `xs` is a 1D array that may not have a `shape` attribute. --- lib/mpl_toolkits/mplot3d/art3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index 8b0669775eaf..5c1825b255b2 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -172,7 +172,7 @@ def __init__(self, xs, ys, zs, *args, **kwargs): def set_3d_properties(self, zs=0, zdir='z'): xs = self.get_xdata() ys = self.get_ydata() - zs = np.broadcast_to(zs, xs.shape) + zs = np.broadcast_to(zs, len(xs)) self._verts3d = juggle_axes(xs, ys, zs, zdir) self.stale = True From adb19faf19f235a69e026ec908382531c0488b0c Mon Sep 17 00:00:00 2001 From: Zexi Date: Fri, 9 Jul 2021 19:39:54 +0800 Subject: [PATCH 2/2] Add test for set_3d_properties --- lib/mpl_toolkits/tests/test_mplot3d.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index ae8e91ddc24d..e8064e0b839d 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -1119,6 +1119,12 @@ def test_line3d_set_get_data_3d(): np.testing.assert_array_equal((x, y, z), line.get_data_3d()) line.set_data_3d(x2, y2, z2) np.testing.assert_array_equal((x2, y2, z2), line.get_data_3d()) + line.set_xdata(x) + line.set_ydata(y) + line.set_3d_properties(zs=z, zdir='z') + np.testing.assert_array_equal((x, y, z), line.get_data_3d()) + line.set_3d_properties(zs=0, zdir='z') + np.testing.assert_array_equal((x, y, np.zeros_like(z)), line.get_data_3d()) @check_figures_equal(extensions=["png"])