@@ -1325,7 +1325,7 @@ def set_adjustable(self, adjustable, share=False):
1325
1325
"""
1326
1326
if adjustable == 'box-forced' :
1327
1327
warnings .warn ("The 'box-forced' keyword argument is deprecated"
1328
- " since 2.2." , cbook .mplDeprecation )
1328
+ " since 2.2." , cbook .mplDeprecation , stacklevel = 2 )
1329
1329
if adjustable not in ('box' , 'datalim' , 'box-forced' ):
1330
1330
raise ValueError ("argument must be 'box', or 'datalim'" )
1331
1331
if share :
@@ -1476,7 +1476,7 @@ def apply_aspect(self, position=None):
1476
1476
if aspect != "auto" :
1477
1477
warnings .warn (
1478
1478
'aspect is not supported for Axes with xscale=%s, '
1479
- 'yscale=%s' % (xscale , yscale ))
1479
+ 'yscale=%s' % (xscale , yscale ), stacklevel = 2 )
1480
1480
aspect = "auto"
1481
1481
else : # some custom projections have their own scales.
1482
1482
pass
@@ -2267,7 +2267,8 @@ def margins(self, *margins, x=None, y=None, tight=True):
2267
2267
2268
2268
if x is None and y is None :
2269
2269
if tight is not True :
2270
- warnings .warn ('ignoring tight=%r in get mode' % (tight ,))
2270
+ warnings .warn ('ignoring tight=%r in get mode' % (tight ,),
2271
+ stacklevel = 2 )
2271
2272
return self ._xmargin , self ._ymargin
2272
2273
2273
2274
if x is not None :
@@ -3091,21 +3092,21 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
3091
3092
warnings .warn (
3092
3093
('Attempting to set identical left==right results\n '
3093
3094
'in singular transformations; automatically expanding.\n '
3094
- 'left=%s, right=%s' ) % (left , right ))
3095
+ 'left=%s, right=%s' ) % (left , right ), stacklevel = 2 )
3095
3096
left , right = mtransforms .nonsingular (left , right , increasing = False )
3096
3097
3097
3098
if self .get_xscale () == 'log' :
3098
3099
if left <= 0 :
3099
3100
warnings .warn (
3100
3101
'Attempted to set non-positive left xlim on a '
3101
3102
'log-scaled axis.\n '
3102
- 'Invalid limit will be ignored.' )
3103
+ 'Invalid limit will be ignored.' , stacklevel = 2 )
3103
3104
left = old_left
3104
3105
if right <= 0 :
3105
3106
warnings .warn (
3106
3107
'Attempted to set non-positive right xlim on a '
3107
3108
'log-scaled axis.\n '
3108
- 'Invalid limit will be ignored.' )
3109
+ 'Invalid limit will be ignored.' , stacklevel = 2 )
3109
3110
right = old_right
3110
3111
3111
3112
left , right = self .xaxis .limit_range_for_scale (left , right )
@@ -3428,7 +3429,7 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
3428
3429
warnings .warn (
3429
3430
('Attempting to set identical bottom==top results\n '
3430
3431
'in singular transformations; automatically expanding.\n '
3431
- 'bottom=%s, top=%s' ) % (bottom , top ))
3432
+ 'bottom=%s, top=%s' ) % (bottom , top ), stacklevel = 2 )
3432
3433
3433
3434
bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
3434
3435
@@ -3437,13 +3438,13 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
3437
3438
warnings .warn (
3438
3439
'Attempted to set non-positive bottom ylim on a '
3439
3440
'log-scaled axis.\n '
3440
- 'Invalid limit will be ignored.' )
3441
+ 'Invalid limit will be ignored.' , stacklevel = 2 )
3441
3442
bottom = old_bottom
3442
3443
if top <= 0 :
3443
3444
warnings .warn (
3444
3445
'Attempted to set non-positive top ylim on a '
3445
3446
'log-scaled axis.\n '
3446
- 'Invalid limit will be ignored.' )
3447
+ 'Invalid limit will be ignored.' , stacklevel = 2 )
3447
3448
top = old_top
3448
3449
bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
3449
3450
@@ -3847,7 +3848,7 @@ def _set_view_from_bbox(self, bbox, direction='in',
3847
3848
# should be len 3 or 4 but nothing else
3848
3849
warnings .warn (
3849
3850
"Warning in _set_view_from_bbox: bounding box is not a tuple "
3850
- "of length 3 or 4. Ignoring the view change." )
3851
+ "of length 3 or 4. Ignoring the view change." , stacklevel = 2 )
3851
3852
return
3852
3853
3853
3854
# Just grab bounding box
@@ -4034,7 +4035,7 @@ def format_deltas(key, dx, dy):
4034
4035
result = (mtransforms .Bbox (newpoints )
4035
4036
.transformed (p .trans_inverse ))
4036
4037
except OverflowError :
4037
- warnings .warn ('Overflow while panning' )
4038
+ warnings .warn ('Overflow while panning' , stacklevel = 2 )
4038
4039
return
4039
4040
else :
4040
4041
return
0 commit comments