@@ -3103,10 +3103,20 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
3103
3103
'left=%s, right=%s' ) % (left , right ))
3104
3104
left , right = mtransforms .nonsingular (left , right , increasing = False )
3105
3105
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
+
3110
3120
left , right = self .xaxis .limit_range_for_scale (left , right )
3111
3121
3112
3122
self .viewLim .intervalx = (left , right )
@@ -3423,10 +3433,19 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
3423
3433
3424
3434
bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
3425
3435
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
3430
3449
bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
3431
3450
3432
3451
self .viewLim .intervaly = (bottom , top )
0 commit comments