@@ -2823,7 +2823,7 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
2823
2823
For example, suppose *x* is years before present.
2824
2824
Then one might use::
2825
2825
2826
- set_ylim (5000, 0)
2826
+ set_xlim (5000, 0)
2827
2827
2828
2828
so 5000 years ago is on the left of the plot and the
2829
2829
present is on the right.
@@ -2861,6 +2861,11 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
2861
2861
'in singular transformations; automatically expanding.\n '
2862
2862
'left=%s, right=%s' ) % (left , right ))
2863
2863
left , right = mtransforms .nonsingular (left , right , increasing = False )
2864
+
2865
+ if self .get_xscale () == 'log' and (left <= 0.0 or right <= 0.0 ):
2866
+ warnings .warn (
2867
+ 'Attempted to set non-positive xlimits for log-scale axis; '
2868
+ 'invalid limits will be ignored.' )
2864
2869
left , right = self .xaxis .limit_range_for_scale (left , right )
2865
2870
2866
2871
self .viewLim .intervalx = (left , right )
@@ -3121,6 +3126,11 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
3121
3126
'bottom=%s, top=%s' ) % (bottom , top ))
3122
3127
3123
3128
bottom , top = mtransforms .nonsingular (bottom , top , increasing = False )
3129
+
3130
+ if self .get_yscale () == 'log' and (bottom <= 0.0 or top <= 0.0 ):
3131
+ warnings .warn (
3132
+ 'Attempted to set non-positive ylimits for log-scale axis; '
3133
+ 'invalid limits will be ignored.' )
3124
3134
bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
3125
3135
3126
3136
self .viewLim .intervaly = (bottom , top )
0 commit comments