@@ -3047,10 +3047,20 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
3047
3047
'left=%s, right=%s' ) % (left , right ))
3048
3048
left , right = mtransforms .nonsingular (left , right , increasing = False )
3049
3049
3050
- if self .get_xscale () == 'log' and (left <= 0.0 or right <= 0.0 ):
3051
- warnings .warn (
3052
- 'Attempted to set non-positive xlimits for log-scale axis; '
3053
- 'invalid limits will be ignored.' )
3050
+ if self .get_xscale () == 'log' :
3051
+ if left <= 0.0 :
3052
+ warnings .warn (
3053
+ 'Attempted to set non-positive left xlim on a '
3054
+ 'log-scaled axis.\n '
3055
+ 'Invalid limit will be ignored.' )
3056
+ left = old_left
3057
+ if right <= 0.0 :
3058
+ warnings .warn (
3059
+ 'Attempted to set non-positive right xlim on a '
3060
+ 'log-scaled axis.\n '
3061
+ 'Invalid limit will be ignored.' )
3062
+ right = old_right
3063
+
3054
3064
left , right = self .xaxis .limit_range_for_scale (left , right )
3055
3065
3056
3066
self .viewLim .intervalx = (left , right )
@@ -3367,10 +3377,19 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
3367
3377
3368
3378
bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
3369
3379
3370
- if self .get_yscale () == 'log' and (bottom <= 0.0 or top <= 0.0 ):
3371
- warnings .warn (
3372
- 'Attempted to set non-positive ylimits for log-scale axis; '
3373
- 'invalid limits will be ignored.' )
3380
+ if self .get_yscale () == 'log' :
3381
+ if bottom <= 0.0 :
3382
+ warnings .warn (
3383
+ 'Attempted to set non-positive bottom ylim on a '
3384
+ 'log-scaled axis.\n '
3385
+ 'Invalid limit will be ignored.' )
3386
+ bottom = old_bottom
3387
+ if top <= 0.0 :
3388
+ warnings .warn (
3389
+ 'Attempted to set non-positive top ylim on a '
3390
+ 'log-scaled axis.\n '
3391
+ 'Invalid limit will be ignored.' )
3392
+ top = old_top
3374
3393
bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
3375
3394
3376
3395
self .viewLim .intervaly = (bottom , top )
0 commit comments