Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f48e3d8

Browse files
authored
Merge pull request #15709 from anntzer/3dplotscalar
Make 3d plot accept scalars as arguments.
2 parents e11f3ef + 78121f5 commit f48e3d8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ def plot(self, xs, ys, *args, zdir='z', **kwargs):
14351435
zs = kwargs.pop('zs', 0)
14361436

14371437
# Match length
1438-
zs = np.broadcast_to(zs, len(xs))
1438+
zs = np.broadcast_to(zs, np.shape(xs))
14391439

14401440
lines = super().plot(xs, ys, *args, **kwargs)
14411441
for line in lines:

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ def test_lines3d():
160160
ax.plot(x, y, z)
161161

162162

163+
@check_figures_equal(extensions=["png"])
164+
def test_plot_scalar(fig_test, fig_ref):
165+
ax1 = fig_test.gca(projection='3d')
166+
ax1.plot([1], [1], "o")
167+
ax2 = fig_ref.gca(projection='3d')
168+
ax2.plot(1, 1, "o")
169+
170+
163171
@image_comparison(['mixedsubplot.png'], remove_text=True)
164172
def test_mixedsubplots():
165173
def f(t):

0 commit comments

Comments
 (0)