From 78121f50dfbd9189c62190949a85a38d8fb5253e Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 17 Nov 2019 18:34:26 +0100 Subject: [PATCH] Make 3d plot accept scalars as arguments. ... for consistency with 2d plot. --- lib/mpl_toolkits/mplot3d/axes3d.py | 2 +- lib/mpl_toolkits/tests/test_mplot3d.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index d4a2699b93e4..a7241b427a35 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1438,7 +1438,7 @@ def plot(self, xs, ys, *args, zdir='z', **kwargs): zs = kwargs.pop('zs', 0) # Match length - zs = np.broadcast_to(zs, len(xs)) + zs = np.broadcast_to(zs, np.shape(xs)) lines = super().plot(xs, ys, *args, **kwargs) for line in lines: diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index 592096b740f9..b79d94530fc2 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -160,6 +160,14 @@ def test_lines3d(): ax.plot(x, y, z) +@check_figures_equal(extensions=["png"]) +def test_plot_scalar(fig_test, fig_ref): + ax1 = fig_test.gca(projection='3d') + ax1.plot([1], [1], "o") + ax2 = fig_ref.gca(projection='3d') + ax2.plot(1, 1, "o") + + @image_comparison(['mixedsubplot.png'], remove_text=True) def test_mixedsubplots(): def f(t):