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

Skip to content

Fix array-like linewidth for 3d scatter #23434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def set_3d_properties(self, zs, zdir):
#
# Grab the current sizes and linewidths to preserve them.
self._sizes3d = self._sizes
self._linewidths3d = self._linewidths
self._linewidths3d = np.array(self._linewidths)
xs, ys, zs = self._offsets3d

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

def get_depthshade(self):
return self._depthshade
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ def test_scatter3d_color():
color='b', marker='s')


@mpl3d_image_comparison(['scatter3d_linewidth.png'])
def test_scatter3d_linewidth():
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

# Check that array-like linewidth can be set
ax.scatter(np.arange(10), np.arange(10), np.arange(10),
marker='o', linewidth=np.arange(10))


@check_figures_equal(extensions=['png'])
def test_scatter3d_linewidth_modification(fig_ref, fig_test):
# Changing Path3DCollection linewidths with array-like post-creation
# should work correctly.
ax_test = fig_test.add_subplot(projection='3d')
c = ax_test.scatter(np.arange(10), np.arange(10), np.arange(10),
marker='o')
c.set_linewidths(np.arange(10))

ax_ref = fig_ref.add_subplot(projection='3d')
ax_ref.scatter(np.arange(10), np.arange(10), np.arange(10), marker='o',
linewidths=np.arange(10))


@check_figures_equal(extensions=['png'])
def test_scatter3d_modification(fig_ref, fig_test):
# Changing Path3DCollection properties post-creation should work correctly.
Expand Down