diff --git a/CHANGELOG b/CHANGELOG index a46c6bdf3a53..b13b6496b253 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2011-08-18 Change api of Axes.get_tightbbox and add an optional + keyword parameter *call_axes_locator*. - JJL + 2011-07-15 The set of markers available in the plot() and scatter() commands has been unified. In general, this gives more options to both than were previously available, however, diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index f1eab53fc514..6904d5786130 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -5770,7 +5770,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, marker_obj.get_transform()) if not marker_obj.is_filled(): edgecolors = 'face' - + collection = mcoll.PathCollection( (path,), scales, facecolors = colors, @@ -8242,11 +8242,16 @@ def matshow(self, Z, **kwargs): integer=True)) return im - - def get_tightbbox(self, renderer): + def get_tightbbox(self, renderer, call_axes_locator=True): """ return the tight bounding box of the axes. The dimension of the Bbox in canvas coordinate. + + If call_axes_locator is False, it does not call the + _axes_locator attribute, which is necessary to get the correct + bounding box. call_axes_locator==False can be used if the + caller is only intereted in the relative size of the tightbbox + compared to the axes bbox. """ artists = [] @@ -8256,7 +8261,7 @@ def get_tightbbox(self, renderer): return None locator = self.get_axes_locator() - if locator: + if locator and call_axes_locator: pos = locator(self, renderer) self.apply_aspect(pos) else: diff --git a/lib/mpl_toolkits/axes_grid1/axes_size.py b/lib/mpl_toolkits/axes_grid1/axes_size.py index 0eda2c822335..6c35e1440b74 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_size.py +++ b/lib/mpl_toolkits/axes_grid1/axes_size.py @@ -270,13 +270,13 @@ def _get_top(tight_bbox, axes_bbox): top=_get_top) del _get_left, _get_right, _get_bottom, _get_top - + def __init__(self, ax, direction): if isinstance(ax, Axes): self._ax_list = [ax] else: self._ax_list = ax - + try: self._get_func = self._get_func_map[direction] except KeyError: @@ -284,8 +284,7 @@ def __init__(self, ax, direction): raise def __call__(self, renderer): - vl = [self._get_func(ax.get_tightbbox(renderer), + vl = [self._get_func(ax.get_tightbbox(renderer, False), ax.bbox) for ax in self._ax_list] return max(vl) - diff --git a/lib/mpl_toolkits/axes_grid1/parasite_axes.py b/lib/mpl_toolkits/axes_grid1/parasite_axes.py index 39a7d981020f..b13de8f69a25 100644 --- a/lib/mpl_toolkits/axes_grid1/parasite_axes.py +++ b/lib/mpl_toolkits/axes_grid1/parasite_axes.py @@ -208,7 +208,7 @@ def parasite_axes_auxtrans_class_factory(axes_class=None): parasite_axes_class = parasite_axes_class_factory(axes_class) else: parasite_axes_class = axes_class - + new_class = _parasite_axes_auxtrans_classes.get(parasite_axes_class) if new_class is None: import new @@ -319,7 +319,7 @@ def twinx(self, axes_class=None): axes_class = self._get_base_axes() parasite_axes_class = parasite_axes_class_factory(axes_class) - + ax2 = parasite_axes_class(self, sharex=self, frameon=False) self.parasites.append(ax2) @@ -353,7 +353,7 @@ def twiny(self, axes_class=None): axes_class = self._get_base_axes() parasite_axes_class = parasite_axes_class_factory(axes_class) - + ax2 = parasite_axes_class(self, sharey=self, frameon=False) self.parasites.append(ax2) @@ -386,7 +386,7 @@ def twin(self, aux_trans=None, axes_class=None): axes_class = self._get_base_axes() parasite_axes_auxtrans_class = parasite_axes_auxtrans_class_factory(axes_class) - + if aux_trans is None: ax2 = parasite_axes_auxtrans_class(self, mtransforms.IdentityTransform(), viewlim_mode="equal", @@ -436,23 +436,24 @@ def twin(self, aux_trans=None, axes_class=None): return ax2 - def get_tightbbox(self, renderer): + def get_tightbbox(self, renderer, call_axes_locator=True): - bbs = [ax.get_tightbbox(renderer) for ax in self.parasites] + bbs = [ax.get_tightbbox(renderer, call_axes_locator) \ + for ax in self.parasites] get_tightbbox = self._get_base_axes_attr("get_tightbbox") - bbs.append(get_tightbbox(self, renderer)) + bbs.append(get_tightbbox(self, renderer, call_axes_locator)) _bbox = Bbox.union([b for b in bbs if b.width!=0 or b.height!=0]) return _bbox - + _host_axes_classes = {} def host_axes_class_factory(axes_class=None): if axes_class is None: axes_class = Axes - + new_class = _host_axes_classes.get(axes_class) if new_class is None: import new diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index 1c9f384f2a74..463752e63f61 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -378,7 +378,7 @@ def get_tick_iterators(self, axes): angle_normal, angle_tangent = 90, 0 else: angle_normal, angle_tangent = 0, 90 - + #angle = 90 - 90 * self.nth_coord major = self.axis.major @@ -459,7 +459,7 @@ def new_fixed_axis(self, loc, offset=None, axes=None, ): - + if axes is None: warnings.warn("'new_fixed_axis' explicitly requires the axes keyword.") axes = self.axes @@ -733,9 +733,9 @@ def draw(self, renderer, inframe=False): self.artists = orig_artists - def get_tightbbox(self, renderer): + def get_tightbbox(self, renderer, call_axes_locator=True): - bb0 = super(Axes, self).get_tightbbox(renderer) + bb0 = super(Axes, self).get_tightbbox(renderer, call_axes_locator) if not self._axisline_on: return bb0 @@ -777,13 +777,13 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, if not swap_axis: return - + if (x1o > x2o and x1 < x2) or (x1o < x2o and x1 > x2): - self.axis["right"], self.axis["left"] = self.axis["left"], self.axis["right"] + self.axis["right"], self.axis["left"] = self.axis["left"], self.axis["right"] self.axis["left"].set_axis_direction("left") self.axis["right"].set_axis_direction("right") - + def set_ylim(self, bottom=None, top=None, emit=True, auto=False, swap_axis=True, **kw): @@ -794,11 +794,11 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, y1, y2 = self.get_ylim() if y1o > y2o and y1 < y2 or (y1o < y2o and y1 > y2): - self.axis["top"], self.axis["bottom"] = self.axis["bottom"], self.axis["top"] + self.axis["top"], self.axis["bottom"] = self.axis["bottom"], self.axis["top"] self.axis["top"].set_axis_direction("top") self.axis["bottom"].set_axis_direction("bottom") - + Subplot = maxes.subplot_class_factory(Axes)