Skip to content

Commit bd9f225

Browse files
committed
Remove deprecated 'smart bounds' functionality.
1 parent aece5b4 commit bd9f225

File tree

4 files changed

+16
-119
lines changed

4 files changed

+16
-119
lines changed

doc/api/axis_api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ Other
225225
Axis.limit_range_for_scale
226226
Axis.reset_ticks
227227
Axis.set_default_intervals
228-
Axis.get_smart_bounds
229-
Axis.set_smart_bounds
230228

231229
Discouraged
232230
-----------

doc/api/next_api_changes/removals/18747-ES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@
1616

1717
- ``quiver.QuiverKey.quiverkey_doc`` has been removed; use
1818
``quiver.QuiverKey.__init__.__doc__`` instead.
19+
20+
Smart bounds
21+
~~~~~~~~~~~~
22+
23+
The "smart bounds" functionality on `~.axis.Axis` and `.Spine` has been
24+
deleted, and the following methods are removed:
25+
26+
- ``Axis.set_smart_bounds`` and ``Axis.get_smart_bounds``
27+
- ``Spine.set_smart_bounds`` and ``Spine.get_smart_bounds``

lib/matplotlib/axis.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ def __init__(self, axes, pickradius=15):
685685
self.callbacks = cbook.CallbackRegistry()
686686

687687
self._autolabelpos = True
688-
self._smart_bounds = False # Deprecated in 3.2
689688

690689
self.label = mtext.Text(
691690
np.nan, np.nan,
@@ -1019,17 +1018,6 @@ def get_ticklabel_extents(self, renderer):
10191018
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
10201019
return bbox, bbox2
10211020

1022-
@cbook.deprecated("3.2")
1023-
def set_smart_bounds(self, value):
1024-
"""Set the axis to have smart bounds."""
1025-
self._smart_bounds = value
1026-
self.stale = True
1027-
1028-
@cbook.deprecated("3.2")
1029-
def get_smart_bounds(self):
1030-
"""Return whether the axis has smart bounds."""
1031-
return self._smart_bounds
1032-
10331021
def _update_ticks(self):
10341022
"""
10351023
Update ticks (position and labels) using the current data interval of
@@ -1057,36 +1045,6 @@ def _update_ticks(self):
10571045
if view_low > view_high:
10581046
view_low, view_high = view_high, view_low
10591047

1060-
if self._smart_bounds and ticks: # _smart_bounds is deprecated in 3.2
1061-
# handle inverted limits
1062-
data_low, data_high = sorted(self.get_data_interval())
1063-
locs = np.sort([tick.get_loc() for tick in ticks])
1064-
if data_low <= view_low:
1065-
# data extends beyond view, take view as limit
1066-
ilow = view_low
1067-
else:
1068-
# data stops within view, take best tick
1069-
good_locs = locs[locs <= data_low]
1070-
if len(good_locs):
1071-
# last tick prior or equal to first data point
1072-
ilow = good_locs[-1]
1073-
else:
1074-
# No ticks (why not?), take first tick
1075-
ilow = locs[0]
1076-
if data_high >= view_high:
1077-
# data extends beyond view, take view as limit
1078-
ihigh = view_high
1079-
else:
1080-
# data stops within view, take best tick
1081-
good_locs = locs[locs >= data_high]
1082-
if len(good_locs):
1083-
# first tick after or equal to last data point
1084-
ihigh = good_locs[0]
1085-
else:
1086-
# No ticks (why not?), take last tick
1087-
ihigh = locs[-1]
1088-
ticks = [tick for tick in ticks if ilow <= tick.get_loc() <= ihigh]
1089-
10901048
interval_t = self.get_transform().transform([view_low, view_high])
10911049

10921050
ticks_to_draw = []

lib/matplotlib/spines.py

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def __init__(self, axes, spine_type, path, **kwargs):
6161
self.set_transform(self.axes.transData) # default transform
6262

6363
self._bounds = None # default bounds
64-
self._smart_bounds = False # deprecated in 3.2
6564

6665
# Defer initial position determination. (Not much support for
6766
# non-rectangular axes is currently implemented, and this lets
@@ -82,23 +81,6 @@ def __init__(self, axes, spine_type, path, **kwargs):
8281
# Note: This cannot be calculated until this is added to an Axes
8382
self._patch_transform = mtransforms.IdentityTransform()
8483

85-
@cbook.deprecated("3.2")
86-
def set_smart_bounds(self, value):
87-
"""Set the spine and associated axis to have smart bounds."""
88-
self._smart_bounds = value
89-
90-
# also set the axis if possible
91-
if self.spine_type in ('left', 'right'):
92-
self.axes.yaxis.set_smart_bounds(value)
93-
elif self.spine_type in ('top', 'bottom'):
94-
self.axes.xaxis.set_smart_bounds(value)
95-
self.stale = True
96-
97-
@cbook.deprecated("3.2")
98-
def get_smart_bounds(self):
99-
"""Return whether the spine has smart bounds."""
100-
return self._smart_bounds
101-
10284
def set_patch_arc(self, center, radius, theta1, theta2):
10385
"""Set the spine to be arc-like."""
10486
self._patch_type = 'arc'
@@ -247,64 +229,14 @@ def _adjust_location(self):
247229
if self.spine_type == 'circle':
248230
return
249231

250-
if self._bounds is None:
251-
if self.spine_type in ('left', 'right'):
252-
low, high = self.axes.viewLim.intervaly
253-
elif self.spine_type in ('top', 'bottom'):
254-
low, high = self.axes.viewLim.intervalx
255-
else:
256-
raise ValueError('unknown spine spine_type: %s' %
257-
self.spine_type)
258-
259-
if self._smart_bounds: # deprecated in 3.2
260-
# attempt to set bounds in sophisticated way
261-
262-
# handle inverted limits
263-
viewlim_low, viewlim_high = sorted([low, high])
264-
265-
if self.spine_type in ('left', 'right'):
266-
datalim_low, datalim_high = self.axes.dataLim.intervaly
267-
ticks = self.axes.get_yticks()
268-
elif self.spine_type in ('top', 'bottom'):
269-
datalim_low, datalim_high = self.axes.dataLim.intervalx
270-
ticks = self.axes.get_xticks()
271-
# handle inverted limits
272-
ticks = np.sort(ticks)
273-
datalim_low, datalim_high = sorted([datalim_low, datalim_high])
274-
275-
if datalim_low < viewlim_low:
276-
# Data extends past view. Clip line to view.
277-
low = viewlim_low
278-
else:
279-
# Data ends before view ends.
280-
cond = (ticks <= datalim_low) & (ticks >= viewlim_low)
281-
tickvals = ticks[cond]
282-
if len(tickvals):
283-
# A tick is less than or equal to lowest data point.
284-
low = tickvals[-1]
285-
else:
286-
# No tick is available
287-
low = datalim_low
288-
low = max(low, viewlim_low)
289-
290-
if datalim_high > viewlim_high:
291-
# Data extends past view. Clip line to view.
292-
high = viewlim_high
293-
else:
294-
# Data ends before view ends.
295-
cond = (ticks >= datalim_high) & (ticks <= viewlim_high)
296-
tickvals = ticks[cond]
297-
if len(tickvals):
298-
# A tick is greater than or equal to highest data
299-
# point.
300-
high = tickvals[0]
301-
else:
302-
# No tick is available
303-
high = datalim_high
304-
high = min(high, viewlim_high)
305-
306-
else:
232+
if self._bounds is not None:
307233
low, high = self._bounds
234+
elif self.spine_type in ('left', 'right'):
235+
low, high = self.axes.viewLim.intervaly
236+
elif self.spine_type in ('top', 'bottom'):
237+
low, high = self.axes.viewLim.intervalx
238+
else:
239+
raise ValueError(f'unknown spine spine_type: {self.spine_type}')
308240

309241
if self._patch_type == 'arc':
310242
if self.spine_type in ('bottom', 'top'):

0 commit comments

Comments
 (0)