@@ -1335,7 +1335,7 @@ def set_adjustable(self, adjustable, share=False):
13351335 """
13361336 if adjustable == 'box-forced' :
13371337 warnings .warn ("The 'box-forced' keyword argument is deprecated"
1338- " since 2.2." , cbook .mplDeprecation )
1338+ " since 2.2." , cbook .mplDeprecation , stacklevel = 2 )
13391339 if adjustable not in ('box' , 'datalim' , 'box-forced' ):
13401340 raise ValueError ("argument must be 'box', or 'datalim'" )
13411341 if share :
@@ -1486,7 +1486,7 @@ def apply_aspect(self, position=None):
14861486 if aspect != "auto" :
14871487 warnings .warn (
14881488 'aspect is not supported for Axes with xscale=%s, '
1489- 'yscale=%s' % (xscale , yscale ))
1489+ 'yscale=%s' % (xscale , yscale ), stacklevel = 2 )
14901490 aspect = "auto"
14911491 else : # some custom projections have their own scales.
14921492 pass
@@ -2287,7 +2287,8 @@ def margins(self, *margins, x=None, y=None, tight=True):
22872287
22882288 if x is None and y is None :
22892289 if tight is not True :
2290- warnings .warn ('ignoring tight=%r in get mode' % (tight ,))
2290+ warnings .warn ('ignoring tight=%r in get mode' % (tight ,),
2291+ stacklevel = 2 )
22912292 return self ._xmargin , self ._ymargin
22922293
22932294 if x is not None :
@@ -3117,21 +3118,21 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
31173118 warnings .warn (
31183119 ('Attempting to set identical left==right results\n '
31193120 'in singular transformations; automatically expanding.\n '
3120- 'left=%s, right=%s' ) % (left , right ))
3121+ 'left=%s, right=%s' ) % (left , right ), stacklevel = 2 )
31213122 left , right = mtransforms .nonsingular (left , right , increasing = False )
31223123
31233124 if self .get_xscale () == 'log' :
31243125 if left <= 0 :
31253126 warnings .warn (
31263127 'Attempted to set non-positive left xlim on a '
31273128 'log-scaled axis.\n '
3128- 'Invalid limit will be ignored.' )
3129+ 'Invalid limit will be ignored.' , stacklevel = 2 )
31293130 left = old_left
31303131 if right <= 0 :
31313132 warnings .warn (
31323133 'Attempted to set non-positive right xlim on a '
31333134 'log-scaled axis.\n '
3134- 'Invalid limit will be ignored.' )
3135+ 'Invalid limit will be ignored.' , stacklevel = 2 )
31353136 right = old_right
31363137
31373138 left , right = self .xaxis .limit_range_for_scale (left , right )
@@ -3456,7 +3457,7 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
34563457 warnings .warn (
34573458 ('Attempting to set identical bottom==top results\n '
34583459 'in singular transformations; automatically expanding.\n '
3459- 'bottom=%s, top=%s' ) % (bottom , top ))
3460+ 'bottom=%s, top=%s' ) % (bottom , top ), stacklevel = 2 )
34603461
34613462 bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
34623463
@@ -3465,13 +3466,13 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
34653466 warnings .warn (
34663467 'Attempted to set non-positive bottom ylim on a '
34673468 'log-scaled axis.\n '
3468- 'Invalid limit will be ignored.' )
3469+ 'Invalid limit will be ignored.' , stacklevel = 2 )
34693470 bottom = old_bottom
34703471 if top <= 0 :
34713472 warnings .warn (
34723473 'Attempted to set non-positive top ylim on a '
34733474 'log-scaled axis.\n '
3474- 'Invalid limit will be ignored.' )
3475+ 'Invalid limit will be ignored.' , stacklevel = 2 )
34753476 top = old_top
34763477 bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
34773478
@@ -3879,7 +3880,7 @@ def _set_view_from_bbox(self, bbox, direction='in',
38793880 # should be len 3 or 4 but nothing else
38803881 warnings .warn (
38813882 "Warning in _set_view_from_bbox: bounding box is not a tuple "
3882- "of length 3 or 4. Ignoring the view change." )
3883+ "of length 3 or 4. Ignoring the view change." , stacklevel = 2 )
38833884 return
38843885
38853886 # Just grab bounding box
@@ -4066,7 +4067,7 @@ def format_deltas(key, dx, dy):
40664067 result = (mtransforms .Bbox (newpoints )
40674068 .transformed (p .trans_inverse ))
40684069 except OverflowError :
4069- warnings .warn ('Overflow while panning' )
4070+ warnings .warn ('Overflow while panning' , stacklevel = 2 )
40704071 return
40714072 else :
40724073 return
0 commit comments