Skip to content

Commit 07929d4

Browse files
committed
Merge pull request #762 from WeatherGod/mplot3d/collection_cmap_fix
Mplot3d/collection cmap fix
2 parents cb94a60 + aa5bdbe commit 07929d4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def do_3d_projection(self, renderer):
183183
segments_2d = [zip(xs, ys) for (xs, ys, zs) in xyslist]
184184
LineCollection.set_segments(self, segments_2d)
185185

186+
# FIXME
186187
minz = 1e9
187188
for (xs, ys, zs) in xyslist:
188189
minz = min(minz, min(zs))
@@ -300,6 +301,9 @@ def set_sort_zpos(self,val):
300301
self._sort_zpos = val
301302

302303
def set_3d_properties(self, zs, zdir):
304+
# Force the collection to initialize the face and edgecolors
305+
# just in case it is a scalarmappable with a colormap.
306+
self.update_scalarmappable()
303307
offsets = self.get_offsets()
304308
if len(offsets) > 0:
305309
xs, ys = zip(*self.get_offsets())
@@ -416,6 +420,9 @@ def set_verts(self, verts, closed=True):
416420
PolyCollection.set_verts(self, [], closed)
417421

418422
def set_3d_properties(self):
423+
# Force the collection to initialize the face and edgecolors
424+
# just in case it is a scalarmappable with a colormap.
425+
self.update_scalarmappable()
419426
self._sort_zpos = None
420427
self.set_zsort(True)
421428
self._facecolors3d = PolyCollection.get_facecolors(self)
@@ -429,7 +436,7 @@ def do_3d_projection(self, renderer):
429436
'''
430437
Perform the 3D projection for this object.
431438
'''
432-
439+
# FIXME: This may no longer be needed?
433440
if self._A is not None:
434441
self.update_scalarmappable()
435442
self._facecolors3d = self._facecolors
@@ -572,6 +579,10 @@ def get_colors(c, num):
572579

573580
def zalpha(colors, zs):
574581
"""Modify the alphas of the color list according to depth"""
582+
# FIXME: This only works well if the points for *zs* are well-spaced
583+
# in all three dimensions. Otherwise, at certain orientations,
584+
# the min and max zs are very close together.
585+
# Should really normalize against the viewing depth.
575586
colors = get_colors(colors, len(zs))
576587
if zs.size > 0 :
577588
norm = Normalize(min(zs), max(zs))

0 commit comments

Comments
 (0)