Skip to content

Commit 3c8a92f

Browse files
committed
MNT: factor updating the 3D colors out into private helper
1 parent c9c0d38 commit 3c8a92f

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def do_3d_projection(self, renderer=None):
301301
"""
302302
Project the points according to renderer matrix.
303303
"""
304+
_update_scalarmappable(self)
304305
xyslist = [proj3d.proj_trans_points(points, self.axes.M)
305306
for points in self._segments3d]
306307
segments_2d = [np.column_stack([xs, ys]) for xs, ys, zs in xyslist]
@@ -486,6 +487,7 @@ def set_3d_properties(self, zs, zdir):
486487

487488
@cbook._delete_parameter('3.4', 'renderer')
488489
def do_3d_projection(self, renderer=None):
490+
_update_scalarmappable(self)
489491
xs, ys, zs = self._offsets3d
490492
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
491493
self.axes.M)
@@ -592,7 +594,7 @@ def set_linewidth(self, lw):
592594

593595
@cbook._delete_parameter('3.4', 'renderer')
594596
def do_3d_projection(self, renderer=None):
595-
self.update_scalarmappable()
597+
_update_scalarmappable(self)
596598
xs, ys, zs = self._offsets3d
597599
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
598600
self.axes.M)
@@ -635,15 +637,15 @@ def do_3d_projection(self, renderer=None):
635637

636638
return np.min(vzs) if vzs.size else np.nan
637639

638-
def update_scalarmappable(self):
639-
copy_state = self._update_dict['array']
640-
ret = super().update_scalarmappable()
641-
if copy_state:
642-
if self._is_filled:
643-
self._facecolor3d = self._facecolors
644-
elif self._is_stroked:
645-
self._edgecolor3d = self._edgecolors
646-
return ret
640+
641+
def _update_scalarmappable(sm):
642+
copy_state = sm._update_dict['array']
643+
ret = sm.update_scalarmappable()
644+
if copy_state:
645+
if sm._is_filled:
646+
sm._facecolor3d = sm._facecolors
647+
elif sm._is_stroked:
648+
sm._edgecolor3d = sm._edgecolors
647649

648650

649651
def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
@@ -783,10 +785,7 @@ def do_3d_projection(self, renderer=None):
783785
"""
784786
Perform the 3D projection for this object.
785787
"""
786-
# FIXME: This may no longer be needed?
787-
if self._A is not None:
788-
self.update_scalarmappable()
789-
self._facecolors3d = self._facecolors
788+
_update_scalarmappable(self)
790789

791790
txs, tys, tzs = proj3d._proj_transform_vec(self._vec, self.axes.M)
792791
xyzlist = [(txs[sl], tys[sl], tzs[sl]) for sl in self._segslices]

0 commit comments

Comments
 (0)