Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ec1c382

Browse filesBrowse files
committed
Deprecate smart_bounds in Axis and Spine.
1 parent 633a83c commit ec1c382
Copy full SHA for ec1c382

File tree

Expand file treeCollapse file tree

3 files changed

+9
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-13
lines changed

‎examples/ticks_and_spines/spine_placement_demo.py

Copy file name to clipboardExpand all lines: examples/ticks_and_spines/spine_placement_demo.py
-9Lines changed: 0 additions & 9 deletions
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

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ def __init__(self, axes, pickradius=15):
763763
self.callbacks = cbook.CallbackRegistry()
764764

765765
self._autolabelpos = True
766-
self._smart_bounds = False
766+
self._smart_bounds = False # Deprecated in 3.2
767767

768768
self.label = self._get_label()
769769
self.labelpad = rcParams['axes.labelpad']
@@ -1085,11 +1085,13 @@ def get_ticklabel_extents(self, renderer):
10851085
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
10861086
return bbox, bbox2
10871087

1088+
@cbook.deprecated("3.2")
10881089
def set_smart_bounds(self, value):
10891090
"""Set the axis to have smart bounds."""
10901091
self._smart_bounds = value
10911092
self.stale = True
10921093

1094+
@cbook.deprecated("3.2")
10931095
def get_smart_bounds(self):
10941096
"""Return whether the axis has smart bounds."""
10951097
return self._smart_bounds
@@ -1121,7 +1123,7 @@ def _update_ticks(self):
11211123
if view_low > view_high:
11221124
view_low, view_high = view_high, view_low
11231125

1124-
if self._smart_bounds and ticks:
1126+
if self._smart_bounds and ticks: # _smart_bounds is deprecated in 3.2
11251127
# handle inverted limits
11261128
data_low, data_high = sorted(self.get_data_interval())
11271129
locs = np.sort([tick.get_loc() for tick in ticks])

‎lib/matplotlib/spines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/spines.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import matplotlib
44
from matplotlib import cbook, docstring, rcParams
55
from matplotlib.artist import allow_rasterization
6+
import matplotlib.cbook as cbook
67
import matplotlib.transforms as mtransforms
78
import matplotlib.patches as mpatches
89
import matplotlib.path as mpath
@@ -56,7 +57,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
5657
self.set_transform(self.axes.transData) # default transform
5758

5859
self._bounds = None # default bounds
59-
self._smart_bounds = False
60+
self._smart_bounds = False # deprecated in 3.2
6061

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

81+
@cbook.deprecated("3.2")
8082
def set_smart_bounds(self, value):
8183
"""Set the spine and associated axis to have smart bounds."""
8284
self._smart_bounds = value
@@ -88,6 +90,7 @@ def set_smart_bounds(self, value):
8890
self.axes.xaxis.set_smart_bounds(value)
8991
self.stale = True
9092

93+
@cbook.deprecated("3.2")
9194
def get_smart_bounds(self):
9295
"""Return whether the spine has smart bounds."""
9396
return self._smart_bounds
@@ -268,7 +271,7 @@ def _adjust_location(self):
268271
raise ValueError('unknown spine spine_type: %s' %
269272
self.spine_type)
270273

271-
if self._smart_bounds:
274+
if self._smart_bounds: # deprecated in 3.2
272275
# attempt to set bounds in sophisticated way
273276

274277
# handle inverted limits

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.