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

Skip to content

Commit be6a950

Browse files
committed
Merged revisions 8732,8734 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v1_0_maint ........ r8732 | efiring | 2010-10-07 08:59:15 +0900 (Thu, 07 Oct 2010) | 3 lines autoscale_view: respect tight kwarg even if only images are present. slight modification of patch by Stan West. ........ r8734 | leejjoon | 2010-10-08 10:23:22 +0900 (Fri, 08 Oct 2010) | 1 line fix bbox_to_anchor for draggable legend ........ svn path=/trunk/matplotlib/; revision=8735
1 parent 8034dc0 commit be6a950

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,12 +1784,13 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
17841784
:meth:`matplotlib.axes.Axes.relim`
17851785
prior to calling autoscale_view.
17861786
"""
1787-
if tight is not None:
1788-
self._tight = bool(tight)
1789-
# if image data only just use the datalim
1790-
_tight = self._tight or (len(self.images)>0 and
1791-
len(self.lines)==0 and
1792-
len(self.patches)==0)
1787+
if tight is None:
1788+
# if image data only just use the datalim
1789+
_tight = self._tight or (len(self.images)>0 and
1790+
len(self.lines)==0 and
1791+
len(self.patches)==0)
1792+
else:
1793+
_tight = self._tight = bool(tight)
17931794

17941795
if scalex and self._autoscaleXon:
17951796
xshared = self._shared_x_axes.get_siblings(self)

lib/matplotlib/legend.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ def finalize_offset(self):
5151
loc_in_canvas = self.get_loc_in_canvas()
5252

5353
bbox = self.legend.get_bbox_to_anchor()
54+
55+
# if bbox has zero width or height, the transformation is
56+
# ill-defined. Fall back to the defaul bbox_to_anchor.
57+
if bbox.width ==0 or bbox.height ==0:
58+
self.legend.set_bbox_to_anchor(None)
59+
bbox = self.legend.get_bbox_to_anchor()
60+
5461
_bbox_transform = BboxTransformFrom(bbox)
5562
self.legend._loc = tuple(_bbox_transform.transform_point(loc_in_canvas))
5663

5764

58-
5965
class Legend(Artist):
6066
"""
6167
Place a legend on the axes at location loc. Labels are a

0 commit comments

Comments
 (0)