Skip to content

Commit 058288a

Browse files
committed
Deprecate smart_bounds in Axis and Spine.
1 parent 7cd5051 commit 058288a

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

examples/ticks_and_spines/spine_placement_demo.py

-9
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
ax.spines['right'].set_color('none')
2323
ax.spines['bottom'].set_position('center')
2424
ax.spines['top'].set_color('none')
25-
ax.spines['left'].set_smart_bounds(True)
26-
ax.spines['bottom'].set_smart_bounds(True)
2725
ax.xaxis.set_ticks_position('bottom')
2826
ax.yaxis.set_ticks_position('left')
2927

@@ -34,8 +32,6 @@
3432
ax.spines['right'].set_color('none')
3533
ax.spines['bottom'].set_position('zero')
3634
ax.spines['top'].set_color('none')
37-
ax.spines['left'].set_smart_bounds(True)
38-
ax.spines['bottom'].set_smart_bounds(True)
3935
ax.xaxis.set_ticks_position('bottom')
4036
ax.yaxis.set_ticks_position('left')
4137

@@ -46,8 +42,6 @@
4642
ax.spines['right'].set_color('none')
4743
ax.spines['bottom'].set_position(('axes', 0.1))
4844
ax.spines['top'].set_color('none')
49-
ax.spines['left'].set_smart_bounds(True)
50-
ax.spines['bottom'].set_smart_bounds(True)
5145
ax.xaxis.set_ticks_position('bottom')
5246
ax.yaxis.set_ticks_position('left')
5347

@@ -58,8 +52,6 @@
5852
ax.spines['right'].set_color('none')
5953
ax.spines['bottom'].set_position(('data', 2))
6054
ax.spines['top'].set_color('none')
61-
ax.spines['left'].set_smart_bounds(True)
62-
ax.spines['bottom'].set_smart_bounds(True)
6355
ax.xaxis.set_ticks_position('bottom')
6456
ax.yaxis.set_ticks_position('left')
6557

@@ -71,7 +63,6 @@ def adjust_spines(ax, spines):
7163
for loc, spine in ax.spines.items():
7264
if loc in spines:
7365
spine.set_position(('outward', 10)) # outward by 10 points
74-
spine.set_smart_bounds(True)
7566
else:
7667
spine.set_color('none') # don't draw spine
7768

lib/matplotlib/axis.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def __init__(self, axes, pickradius=15):
713713
self.callbacks = cbook.CallbackRegistry()
714714

715715
self._autolabelpos = True
716-
self._smart_bounds = False
716+
self._smart_bounds = False # Deprecated in 3.0
717717

718718
self.label = self._get_label()
719719
self.labelpad = rcParams['axes.labelpad']
@@ -1003,11 +1003,13 @@ def get_ticklabel_extents(self, renderer):
10031003
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
10041004
return bbox, bbox2
10051005

1006+
@cbook.deprecated("3.0")
10061007
def set_smart_bounds(self, value):
10071008
"""set the axis to have smart bounds"""
10081009
self._smart_bounds = value
10091010
self.stale = True
10101011

1012+
@cbook.deprecated("3.0")
10111013
def get_smart_bounds(self):
10121014
"""get whether the axis has smart bounds"""
10131015
return self._smart_bounds
@@ -1025,7 +1027,7 @@ def _update_ticks(self, renderer=None):
10251027
" is ignored and will be removed in 3.1")
10261028
interval = self.get_view_interval()
10271029
tick_tups = list(self.iter_ticks()) # iter_ticks calls the locator
1028-
if self._smart_bounds and tick_tups:
1030+
if self._smart_bounds and tick_tups: # _smart_bounds is deprecated
10291031
# handle inverted limits
10301032
view_low, view_high = sorted(interval)
10311033
data_low, data_high = sorted(self.get_data_interval())

lib/matplotlib/spines.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import matplotlib
66
from matplotlib import docstring, rcParams
77
from matplotlib.artist import allow_rasterization
8+
import matplotlib.cbook as cbook
89
import matplotlib.transforms as mtransforms
910
import matplotlib.patches as mpatches
1011
import matplotlib.path as mpath
@@ -57,7 +58,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
5758
self.set_transform(self.axes.transData) # default transform
5859

5960
self._bounds = None # default bounds
60-
self._smart_bounds = False
61+
self._smart_bounds = False # deprecated in 3.0
6162

6263
# Defer initial position determination. (Not much support for
6364
# non-rectangular axes is currently implemented, and this lets
@@ -80,6 +81,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
8081
# Note: This cannot be calculated until this is added to an Axes
8182
self._patch_transform = mtransforms.IdentityTransform()
8283

84+
@cbook.deprecated("3.0")
8385
def set_smart_bounds(self, value):
8486
"""set the spine and associated axis to have smart bounds"""
8587
self._smart_bounds = value
@@ -91,6 +93,7 @@ def set_smart_bounds(self, value):
9193
self.axes.xaxis.set_smart_bounds(value)
9294
self.stale = True
9395

96+
@cbook.deprecated("3.0")
9497
def get_smart_bounds(self):
9598
"""get whether the spine has smart bounds"""
9699
return self._smart_bounds
@@ -215,7 +218,7 @@ def _adjust_location(self):
215218
raise ValueError('unknown spine spine_type: %s' %
216219
self.spine_type)
217220

218-
if self._smart_bounds:
221+
if self._smart_bounds: # deprecated in 3.0
219222
# attempt to set bounds in sophisticated way
220223

221224
# handle inverted limits

0 commit comments

Comments
 (0)