File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -533,6 +533,21 @@ def set_sort_zpos(self, val):
533
533
self ._sort_zpos = val
534
534
self .stale = True
535
535
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
+
536
551
def set_3d_properties (self , zs , zdir ):
537
552
# Force the collection to initialize the face and edgecolors
538
553
# just in case it is a scalarmappable with a colormap.
Original file line number Diff line number Diff line change @@ -1116,6 +1116,26 @@ def test_line3d_set_get_data_3d():
1116
1116
np .testing .assert_array_equal ((x2 , y2 , z2 ), line .get_data_3d ())
1117
1117
1118
1118
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
+
1119
1139
@check_figures_equal (extensions = ["png" ])
1120
1140
def test_inverted (fig_test , fig_ref ):
1121
1141
# Plot then invert.
You can’t perform that action at this time.
0 commit comments