Skip to content

Add get/set color methods for some 3d collections #5598

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

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 28 additions & 4 deletions lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,18 @@ def __init__(self, *args, **kwargs):
PatchCollection.__init__(self, *args, **kwargs)
self.set_3d_properties(zs, zdir)

def set_facecolor(self, c):
PatchCollection.set_facecolor(self, c)
self._facecolor3d = self.get_facecolor()
set_facecolor.__doc__ = PatchCollection.set_facecolor.__doc__
set_facecolors = set_facecolor

def set_edgecolor(self, c):
PatchCollection.set_edgecolor(self, c)
self._edgecolor3d = self.get_edgecolor()
set_edgecolor.__doc__ = PatchCollection.set_edgecolor.__doc__
set_edgecolors = set_edgecolor

def set_sort_zpos(self, val):
'''Set the position to use for z-sorting.'''
self._sort_zpos = val
Expand Down Expand Up @@ -390,12 +402,12 @@ def do_3d_projection(self, renderer):
fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else
self._facecolor3d)
fcs = mcolors.colorConverter.to_rgba_array(fcs, self._alpha)
self.set_facecolors(fcs)
PatchCollection.set_facecolors(self, fcs)

ecs = (zalpha(self._edgecolor3d, vzs) if self._depthshade else
self._edgecolor3d)
ecs = mcolors.colorConverter.to_rgba_array(ecs, self._alpha)
self.set_edgecolors(ecs)
PatchCollection.set_edgecolors(self, ecs)
PatchCollection.set_offsets(self, list(zip(vxs, vys)))

if vzs.size > 0:
Expand Down Expand Up @@ -451,19 +463,31 @@ def set_3d_properties(self, zs, zdir):
self._edgecolor3d = self.get_edgecolor()
self.stale = True

def set_facecolor(self, c):
PathCollection.set_facecolor(self, c)
self._facecolor3d = self.get_facecolor()
set_facecolor.__doc__ = PathCollection.set_facecolor.__doc__
set_facecolors = set_facecolor

def set_edgecolor(self, c):
PathCollection.set_edgecolor(self, c)
self._edgecolor3d = self.get_edgecolor()
set_edgecolor.__doc__ = PathCollection.set_edgecolor.__doc__
set_edgecolors = set_edgecolor

def do_3d_projection(self, renderer):
xs, ys, zs = self._offsets3d
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)

fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else
self._facecolor3d)
fcs = mcolors.colorConverter.to_rgba_array(fcs, self._alpha)
self.set_facecolors(fcs)
PathCollection.set_facecolors(self, fcs)

ecs = (zalpha(self._edgecolor3d, vzs) if self._depthshade else
self._edgecolor3d)
ecs = mcolors.colorConverter.to_rgba_array(ecs, self._alpha)
self.set_edgecolors(ecs)
PathCollection.set_edgecolors(self, ecs)
PathCollection.set_offsets(self, list(zip(vxs, vys)))

if vzs.size > 0 :
Expand Down