Skip to content

Commit 83692e0

Browse files
committed
Merge branch 'yannpaul-colormapInitBug2'
2 parents a3bbc7b + 071a0b8 commit 83692e0

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

lib/matplotlib/axes.py

+7
Original file line numberDiff line numberDiff line change
@@ -8305,6 +8305,13 @@ def matshow(self, Z, **kwargs):
83058305
integer=True))
83068306
return im
83078307

8308+
def get_default_bbox_extra_artists(self):
8309+
bbox_extra_artists = [t for t in self.texts if t.get_visible()]
8310+
if self.legend_:
8311+
bbox_extra_artists.append(self.legend_)
8312+
return bbox_extra_artists
8313+
8314+
83088315
def get_tightbbox(self, renderer, call_axes_locator=True):
83098316
"""
83108317
return the tight bounding box of the axes.

lib/matplotlib/backend_bases.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2003,8 +2003,12 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
20032003
renderer = self.figure._cachedRenderer
20042004
bbox_inches = self.figure.get_tightbbox(renderer)
20052005

2006-
bb = [a.get_window_extent(renderer) for a \
2007-
in kwargs.pop("bbox_extra_artists", [])]
2006+
bbox_extra_artists = kwargs.pop("bbox_extra_artists", None)
2007+
if bbox_extra_artists is None:
2008+
bbox_extra_artists = self.figure.get_default_bbox_extra_artists()
2009+
2010+
bb = [a.get_window_extent(renderer) for a in bbox_extra_artists]
2011+
20082012
if bb:
20092013
_bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
20102014

lib/matplotlib/colors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def _set_extremes(self):
602602
self._lut[self._i_over] = self._lut[self.N-1]
603603
self._lut[self._i_bad] = self._rgba_bad
604604

605-
def _init():
605+
def _init(self):
606606
'''Generate the lookup table, self._lut'''
607607
raise NotImplementedError("Abstract class only")
608608

lib/matplotlib/figure.py

+7
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,13 @@ def waitforbuttonpress(self, timeout=-1):
12881288
return blocking_input(timeout=timeout)
12891289

12901290

1291+
def get_default_bbox_extra_artists(self):
1292+
bbox_extra_artists = [t for t in self.texts if t.get_visible()]
1293+
for ax in self.axes:
1294+
if ax.get_visible():
1295+
bbox_extra_artists.extend(ax.get_default_bbox_extra_artists())
1296+
return bbox_extra_artists
1297+
12911298

12921299
def get_tightbbox(self, renderer):
12931300
"""

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))

lib/mpl_toolkits/mplot3d/axes3d.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ def can_pan(self) :
825825
def cla(self):
826826
"""Clear axes and disable mouse button callbacks.
827827
"""
828-
self.disable_mouse_rotation()
828+
# Disabling mouse interaction might have been needed a long
829+
# time ago, but I can't find a reason for it now - BVR (2012-03)
830+
#self.disable_mouse_rotation()
829831
self.zaxis.cla()
830832

831833
# TODO: Support sharez

0 commit comments

Comments
 (0)