Skip to content

Commit 16ad86e

Browse files
authored
Merge pull request matplotlib#23434 from krassowski/fix-23433
FIX: array-like linewidth for 3d scatter
2 parents 2d5a8ec + 7fd98f1 commit 16ad86e

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def set_3d_properties(self, zs, zdir):
545545
#
546546
# Grab the current sizes and linewidths to preserve them.
547547
self._sizes3d = self._sizes
548-
self._linewidths3d = self._linewidths
548+
self._linewidths3d = np.array(self._linewidths)
549549
xs, ys, zs = self._offsets3d
550550

551551
# Sort the points based on z coordinates
@@ -563,7 +563,7 @@ def set_sizes(self, sizes, dpi=72.0):
563563
def set_linewidth(self, lw):
564564
super().set_linewidth(lw)
565565
if not self._in_draw:
566-
self._linewidth3d = lw
566+
self._linewidths3d = np.array(self._linewidths)
567567

568568
def get_depthshade(self):
569569
return self._depthshade
Loading

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,30 @@ def test_scatter3d_color():
325325
color='b', marker='s')
326326

327327

328+
@mpl3d_image_comparison(['scatter3d_linewidth.png'])
329+
def test_scatter3d_linewidth():
330+
fig = plt.figure()
331+
ax = fig.add_subplot(projection='3d')
332+
333+
# Check that array-like linewidth can be set
334+
ax.scatter(np.arange(10), np.arange(10), np.arange(10),
335+
marker='o', linewidth=np.arange(10))
336+
337+
338+
@check_figures_equal(extensions=['png'])
339+
def test_scatter3d_linewidth_modification(fig_ref, fig_test):
340+
# Changing Path3DCollection linewidths with array-like post-creation
341+
# should work correctly.
342+
ax_test = fig_test.add_subplot(projection='3d')
343+
c = ax_test.scatter(np.arange(10), np.arange(10), np.arange(10),
344+
marker='o')
345+
c.set_linewidths(np.arange(10))
346+
347+
ax_ref = fig_ref.add_subplot(projection='3d')
348+
ax_ref.scatter(np.arange(10), np.arange(10), np.arange(10), marker='o',
349+
linewidths=np.arange(10))
350+
351+
328352
@check_figures_equal(extensions=['png'])
329353
def test_scatter3d_modification(fig_ref, fig_test):
330354
# Changing Path3DCollection properties post-creation should work correctly.

0 commit comments

Comments
 (0)