diff --git a/doc/api/next_api_changes/2019-07-16-EF.rst b/doc/api/next_api_changes/2019-07-16-EF.rst new file mode 100644 index 000000000000..15143065960e --- /dev/null +++ b/doc/api/next_api_changes/2019-07-16-EF.rst @@ -0,0 +1,6 @@ +Deprecations +```````````` + +The "smart_bounds" functionality is deprecated. This includes +``Axis.set_smart_bounds()``, ``Axis.get_smart_bounds()``, +``Spine.set_smart_bounds()``, and ``Spine.get_smart_bounds()``. diff --git a/examples/ticks_and_spines/spine_placement_demo.py b/examples/ticks_and_spines/spine_placement_demo.py index ca2543344554..6e52eae7908e 100644 --- a/examples/ticks_and_spines/spine_placement_demo.py +++ b/examples/ticks_and_spines/spine_placement_demo.py @@ -22,8 +22,6 @@ ax.spines['right'].set_color('none') ax.spines['bottom'].set_position('center') ax.spines['top'].set_color('none') -ax.spines['left'].set_smart_bounds(True) -ax.spines['bottom'].set_smart_bounds(True) ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') @@ -34,8 +32,6 @@ ax.spines['right'].set_color('none') ax.spines['bottom'].set_position('zero') ax.spines['top'].set_color('none') -ax.spines['left'].set_smart_bounds(True) -ax.spines['bottom'].set_smart_bounds(True) ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') @@ -46,8 +42,6 @@ ax.spines['right'].set_color('none') ax.spines['bottom'].set_position(('axes', 0.1)) ax.spines['top'].set_color('none') -ax.spines['left'].set_smart_bounds(True) -ax.spines['bottom'].set_smart_bounds(True) ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') @@ -58,8 +52,6 @@ ax.spines['right'].set_color('none') ax.spines['bottom'].set_position(('data', 2)) ax.spines['top'].set_color('none') -ax.spines['left'].set_smart_bounds(True) -ax.spines['bottom'].set_smart_bounds(True) ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') @@ -71,7 +63,6 @@ def adjust_spines(ax, spines): for loc, spine in ax.spines.items(): if loc in spines: spine.set_position(('outward', 10)) # outward by 10 points - spine.set_smart_bounds(True) else: spine.set_color('none') # don't draw spine diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 98f8bc73e0d8..db8a41e628e5 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -763,7 +763,7 @@ def __init__(self, axes, pickradius=15): self.callbacks = cbook.CallbackRegistry() self._autolabelpos = True - self._smart_bounds = False + self._smart_bounds = False # Deprecated in 3.2 self.label = self._get_label() self.labelpad = rcParams['axes.labelpad'] @@ -1085,11 +1085,13 @@ def get_ticklabel_extents(self, renderer): bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0) return bbox, bbox2 + @cbook.deprecated("3.2") def set_smart_bounds(self, value): """Set the axis to have smart bounds.""" self._smart_bounds = value self.stale = True + @cbook.deprecated("3.2") def get_smart_bounds(self): """Return whether the axis has smart bounds.""" return self._smart_bounds @@ -1121,7 +1123,7 @@ def _update_ticks(self): if view_low > view_high: view_low, view_high = view_high, view_low - if self._smart_bounds and ticks: + if self._smart_bounds and ticks: # _smart_bounds is deprecated in 3.2 # handle inverted limits data_low, data_high = sorted(self.get_data_interval()) locs = np.sort([tick.get_loc() for tick in ticks]) diff --git a/lib/matplotlib/spines.py b/lib/matplotlib/spines.py index aecd9c320492..1b2e714bcdc5 100644 --- a/lib/matplotlib/spines.py +++ b/lib/matplotlib/spines.py @@ -3,6 +3,7 @@ import matplotlib from matplotlib import cbook, docstring, rcParams from matplotlib.artist import allow_rasterization +import matplotlib.cbook as cbook import matplotlib.transforms as mtransforms import matplotlib.patches as mpatches import matplotlib.path as mpath @@ -56,7 +57,7 @@ def __init__(self, axes, spine_type, path, **kwargs): self.set_transform(self.axes.transData) # default transform self._bounds = None # default bounds - self._smart_bounds = False + self._smart_bounds = False # deprecated in 3.2 # Defer initial position determination. (Not much support for # non-rectangular axes is currently implemented, and this lets @@ -77,6 +78,7 @@ def __init__(self, axes, spine_type, path, **kwargs): # Note: This cannot be calculated until this is added to an Axes self._patch_transform = mtransforms.IdentityTransform() + @cbook.deprecated("3.2") def set_smart_bounds(self, value): """Set the spine and associated axis to have smart bounds.""" self._smart_bounds = value @@ -88,6 +90,7 @@ def set_smart_bounds(self, value): self.axes.xaxis.set_smart_bounds(value) self.stale = True + @cbook.deprecated("3.2") def get_smart_bounds(self): """Return whether the spine has smart bounds.""" return self._smart_bounds @@ -268,7 +271,7 @@ def _adjust_location(self): raise ValueError('unknown spine spine_type: %s' % self.spine_type) - if self._smart_bounds: + if self._smart_bounds: # deprecated in 3.2 # attempt to set bounds in sophisticated way # handle inverted limits