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

Skip to content

bug fix - set_facecolors not working for 3D scatter #10489

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
Closed
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
56 changes: 55 additions & 1 deletion lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'''
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import types
import six
from six.moves import zip

Expand Down Expand Up @@ -495,6 +495,60 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
col._depthshade = depthshade
col.set_3d_properties(zs, zdir)

def set_facecolor3d(self, c):
"""
Set the facecolor(s) of the collection. *c* can be a
matplotlib color spec (all patches have same color), or a
sequence of specs; if it is a sequence the patches will
cycle through the sequence.

If *c* is 'none', the patch will not be filled.

ACCEPTS: matplotlib color spec or sequence of specs
"""
self.set_facecolor2d(c)

c = self.get_facecolor().copy() # new color
length_old = self._facecolor3d.shape[0]
length_new = c.shape[0]
# reset alpha value to original
if (length_new > length_old):
c[:, 3] = self._facecolor3d[0, 3]
elif (length_new == length_old):
c[:, 3] = self._facecolor3d[:, 3]
self._facecolor3d = c

def set_edgecolor3d(self, c):
"""
Set the edgecolor(s) of the collection. *c* can be a
matplotlib color spec (all patches have same color), or a
sequence of specs; if it is a sequence the patches will
cycle through the sequence.

If *c* is 'face', the edge color will always be the same as
the face color. If it is 'none', the patch boundary will not
be drawn.

ACCEPTS: matplotlib color spec or sequence of specs
"""
self.set_edgecolor2d(c)

c = self.get_edgecolor().copy() # new color
length_old = self._edgecolor3d.shape[0]
length_new = c.shape[0]

# reset alpha value to original
if (length_new > length_old):
c[:, 3] = self._edgecolor3d[0, 3]
elif (length_new == length_old):
c[:, 3] = self._edgecolor3d[:, 3]
self._edgecolor3d = c

col.set_facecolor2d = col.set_facecolor
col.set_facecolor = types.MethodType(set_facecolor3d, col)
col.set_edgecolor2d = col.set_edgecolor
col.set_edgecolor = types.MethodType(set_edgecolor3d, col)


class Poly3DCollection(PolyCollection):
'''
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading