@@ -3103,10 +3103,20 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
31033103 'left=%s, right=%s' ) % (left , right ))
31043104 left , right = mtransforms .nonsingular (left , right , increasing = False )
31053105
3106- if self .get_xscale () == 'log' and (left <= 0.0 or right <= 0.0 ):
3107- warnings .warn (
3108- 'Attempted to set non-positive xlimits for log-scale axis; '
3109- 'invalid limits will be ignored.' )
3106+ if self .get_xscale () == 'log' :
3107+ if left <= 0 :
3108+ warnings .warn (
3109+ 'Attempted to set non-positive left xlim on a '
3110+ 'log-scaled axis.\n '
3111+ 'Invalid limit will be ignored.' )
3112+ left = old_left
3113+ if right <= 0 :
3114+ warnings .warn (
3115+ 'Attempted to set non-positive right xlim on a '
3116+ 'log-scaled axis.\n '
3117+ 'Invalid limit will be ignored.' )
3118+ right = old_right
3119+
31103120 left , right = self .xaxis .limit_range_for_scale (left , right )
31113121
31123122 self .viewLim .intervalx = (left , right )
@@ -3423,10 +3433,19 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
34233433
34243434 bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
34253435
3426- if self .get_yscale () == 'log' and (bottom <= 0.0 or top <= 0.0 ):
3427- warnings .warn (
3428- 'Attempted to set non-positive ylimits for log-scale axis; '
3429- 'invalid limits will be ignored.' )
3436+ if self .get_yscale () == 'log' :
3437+ if bottom <= 0 :
3438+ warnings .warn (
3439+ 'Attempted to set non-positive bottom ylim on a '
3440+ 'log-scaled axis.\n '
3441+ 'Invalid limit will be ignored.' )
3442+ bottom = old_bottom
3443+ if top <= 0 :
3444+ warnings .warn (
3445+ 'Attempted to set non-positive top ylim on a '
3446+ 'log-scaled axis.\n '
3447+ 'Invalid limit will be ignored.' )
3448+ top = old_top
34303449 bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
34313450
34323451 self .viewLim .intervaly = (bottom , top )
0 commit comments