Skip to content

Commit dda42ab

Browse files
committed
Change default behaviour of setting logscale to 'mask'
1 parent 1bf8282 commit dda42ab

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Default behavior of log scales changed to mask <= 0 values
2+
``````````````````````````````````````````````````````````
3+
4+
Calling `matplotlib.Axes.set_xscale` or `matplotlib.Axes.set_yscale` now uses
5+
'mask' as the default method to handle invalid values (as opposed to 'clip').
6+
This means that any values <= 0 on a log scale will not be shown.
7+
8+
Previously they were clipped to a very small number and shown.

lib/matplotlib/axes/_axes.py

-2
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,6 @@ def semilogx(self, *args, **kwargs):
15781578
self.cla()
15791579
d = {'basex': kwargs.pop('basex', 10),
15801580
'subsx': kwargs.pop('subsx', None),
1581-
'nonposx': kwargs.pop('nonposx', 'mask'),
15821581
}
15831582

15841583
self.set_xscale('log', **d)
@@ -1629,7 +1628,6 @@ def semilogy(self, *args, **kwargs):
16291628
self.cla()
16301629
d = {'basey': kwargs.pop('basey', 10),
16311630
'subsy': kwargs.pop('subsy', None),
1632-
'nonposy': kwargs.pop('nonposy', 'mask'),
16331631
}
16341632
self.set_yscale('log', **d)
16351633
b = self._hold

lib/matplotlib/axes/_base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2961,10 +2961,10 @@ def set_xscale(self, value, **kwargs):
29612961
29622962
matplotlib.scale.LogisticTransform : logit transform
29632963
"""
2964-
# If the scale is being set to log, clip nonposx to prevent headaches
2964+
# If the scale is being set to log, mask nonposx to prevent headaches
29652965
# around zero
29662966
if value.lower() == 'log' and 'nonposx' not in kwargs:
2967-
kwargs['nonposx'] = 'clip'
2967+
kwargs['nonposx'] = 'mask'
29682968

29692969
g = self.get_shared_x_axes()
29702970
for ax in g.get_siblings(self):
@@ -3255,10 +3255,10 @@ def set_yscale(self, value, **kwargs):
32553255
32563256
matplotlib.scale.LogisticTransform : logit transform
32573257
"""
3258-
# If the scale is being set to log, clip nonposy to prevent headaches
3258+
# If the scale is being set to log, mask nonposy to prevent headaches
32593259
# around zero
32603260
if value.lower() == 'log' and 'nonposy' not in kwargs:
3261-
kwargs['nonposy'] = 'clip'
3261+
kwargs['nonposy'] = 'mask'
32623262

32633263
g = self.get_shared_y_axes()
32643264
for ax in g.get_siblings(self):

0 commit comments

Comments
 (0)