Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f70c15

Browse filesBrowse files
committed
create set_offsets3d for PathCollection3d
1 parent a510e32 commit 7f70c15
Copy full SHA for 7f70c15

File tree

2 files changed

+35
-0
lines changed
Filter options

2 files changed

+35
-0
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,21 @@ def set_sort_zpos(self, val):
533533
self._sort_zpos = val
534534
self.stale = True
535535

536+
def get_offsets3d(self):
537+
"""Return the 3d offsets for the collection as numpy array."""
538+
return np.array(self._offsets3d).T
539+
540+
def set_offsets3d(self, offsets):
541+
"""
542+
Set the offsets for the collection.
543+
544+
Parameters
545+
----------
546+
offsets : (N, 3) array-like
547+
"""
548+
self._offsets3d = np.asanyarray(offsets).T
549+
self.stale = True
550+
536551
def set_3d_properties(self, zs, zdir):
537552
# Force the collection to initialize the face and edgecolors
538553
# just in case it is a scalarmappable with a colormap.

‎lib/mpl_toolkits/tests/test_mplot3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_mplot3d.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,26 @@ def test_line3d_set_get_data_3d():
11161116
np.testing.assert_array_equal((x2, y2, z2), line.get_data_3d())
11171117

11181118

1119+
def test_PathCollection3d_set_get_offsets_3d():
1120+
orig = np.array([
1121+
[0, 1, 1],
1122+
[2, 3, 2]
1123+
])
1124+
1125+
new = np.array([
1126+
[6, 7, 4],
1127+
[8, 9, 5],
1128+
[10, 11, 6]
1129+
])
1130+
1131+
fig = plt.figure()
1132+
ax = fig.add_subplot(projection='3d')
1133+
scat = ax.scatter(*orig.T)
1134+
np.testing.assert_array_equal(orig, scat.get_offsets3d())
1135+
scat.set_offsets3d(new)
1136+
np.testing.assert_array_equal(new, scat.get_offsets3d())
1137+
1138+
11191139
@check_figures_equal(extensions=["png"])
11201140
def test_inverted(fig_test, fig_ref):
11211141
# Plot then invert.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.