@@ -1325,7 +1325,7 @@ def set_adjustable(self, adjustable, share=False):
13251325 """
13261326 if adjustable == 'box-forced' :
13271327 warnings .warn ("The 'box-forced' keyword argument is deprecated"
1328- " since 2.2." , cbook .mplDeprecation )
1328+ " since 2.2." , cbook .mplDeprecation , stacklevel = 2 )
13291329 if adjustable not in ('box' , 'datalim' , 'box-forced' ):
13301330 raise ValueError ("argument must be 'box', or 'datalim'" )
13311331 if share :
@@ -1476,7 +1476,7 @@ def apply_aspect(self, position=None):
14761476 if aspect != "auto" :
14771477 warnings .warn (
14781478 'aspect is not supported for Axes with xscale=%s, '
1479- 'yscale=%s' % (xscale , yscale ))
1479+ 'yscale=%s' % (xscale , yscale ), stacklevel = 2 )
14801480 aspect = "auto"
14811481 else : # some custom projections have their own scales.
14821482 pass
@@ -2267,7 +2267,8 @@ def margins(self, *margins, x=None, y=None, tight=True):
22672267
22682268 if x is None and y is None :
22692269 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 )
22712272 return self ._xmargin , self ._ymargin
22722273
22732274 if x is not None :
@@ -3091,21 +3092,21 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
30913092 warnings .warn (
30923093 ('Attempting to set identical left==right results\n '
30933094 'in singular transformations; automatically expanding.\n '
3094- 'left=%s, right=%s' ) % (left , right ))
3095+ 'left=%s, right=%s' ) % (left , right ), stacklevel = 2 )
30953096 left , right = mtransforms .nonsingular (left , right , increasing = False )
30963097
30973098 if self .get_xscale () == 'log' :
30983099 if left <= 0 :
30993100 warnings .warn (
31003101 'Attempted to set non-positive left xlim on a '
31013102 'log-scaled axis.\n '
3102- 'Invalid limit will be ignored.' )
3103+ 'Invalid limit will be ignored.' , stacklevel = 2 )
31033104 left = old_left
31043105 if right <= 0 :
31053106 warnings .warn (
31063107 'Attempted to set non-positive right xlim on a '
31073108 'log-scaled axis.\n '
3108- 'Invalid limit will be ignored.' )
3109+ 'Invalid limit will be ignored.' , stacklevel = 2 )
31093110 right = old_right
31103111
31113112 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,
34283429 warnings .warn (
34293430 ('Attempting to set identical bottom==top results\n '
34303431 'in singular transformations; automatically expanding.\n '
3431- 'bottom=%s, top=%s' ) % (bottom , top ))
3432+ 'bottom=%s, top=%s' ) % (bottom , top ), stacklevel = 2 )
34323433
34333434 bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
34343435
@@ -3437,13 +3438,13 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
34373438 warnings .warn (
34383439 'Attempted to set non-positive bottom ylim on a '
34393440 'log-scaled axis.\n '
3440- 'Invalid limit will be ignored.' )
3441+ 'Invalid limit will be ignored.' , stacklevel = 2 )
34413442 bottom = old_bottom
34423443 if top <= 0 :
34433444 warnings .warn (
34443445 'Attempted to set non-positive top ylim on a '
34453446 'log-scaled axis.\n '
3446- 'Invalid limit will be ignored.' )
3447+ 'Invalid limit will be ignored.' , stacklevel = 2 )
34473448 top = old_top
34483449 bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
34493450
@@ -3847,7 +3848,7 @@ def _set_view_from_bbox(self, bbox, direction='in',
38473848 # should be len 3 or 4 but nothing else
38483849 warnings .warn (
38493850 "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 )
38513852 return
38523853
38533854 # Just grab bounding box
@@ -4034,7 +4035,7 @@ def format_deltas(key, dx, dy):
40344035 result = (mtransforms .Bbox (newpoints )
40354036 .transformed (p .trans_inverse ))
40364037 except OverflowError :
4037- warnings .warn ('Overflow while panning' )
4038+ warnings .warn ('Overflow while panning' , stacklevel = 2 )
40384039 return
40394040 else :
40404041 return
0 commit comments