8000 Mask invalid values by default when setting log scale by dstansby · Pull Request #8836 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Mask invalid values by default when setting log scale #8836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Change default behaviour of setting logscale to 'mask'
  • Loading branch information
dstansby committed Jul 3, 2017
commit dda42abd96332578d6764c8f00ae6f520f0691bd
8 changes: 8 additions & 0 deletions doc/api/api_changes/2017-07-03-DS-logscale_masked.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Default behavior of log scales changed to mask <= 0 values
``````````````````````````````````````````````````````````

Calling `matplotlib.Axes.set_xscale` or `matplotlib.Axes.set_yscale` now uses
'mask' as the default method to handle invalid values (as opposed to 'clip').
This means that any values <= 0 on a log scale will not be shown.

Previously they were clipped to a very small number and shown.
2 changes: 0 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,6 @@ def semilogx(self, *args, **kwargs):
self.cla()
d = {'basex': kwargs.pop('basex', 10),
'subsx': kwargs.pop('subsx', None),
'nonposx': kwargs.pop('nonposx', 'mask'),
}

self.set_xscale('log', **d)
Expand Down Expand Up @@ -1629,7 +1628,6 @@ def semilogy(self, *args, **kwargs):
self.cla()
d = {'basey': kwargs.pop('basey', 10),
'subsy': kwargs.pop('subsy', None),
'nonposy': kwargs.pop('nonposy', 'mask'),
}
self.set_yscale('log', **d)
b = self._hold
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2961,10 +2961,10 @@ def set_xscale(self, value, **kwargs):

matplotlib.scale.LogisticTransform : logit transform
"""
# If the scale is being set to log, clip nonposx to prevent headaches
# If the scale is being set to log, mask nonposx to prevent headaches
# around zero
if value.lower() == 'log' and 'nonposx' not in kwargs:
kwargs['nonposx'] = 'clip'
kwargs['nonposx'] = 'mask'

g = self.get_shared_x_axes()
for ax in g.get_siblings(self):
Expand Down Expand Up @@ -3255,10 +3255,10 @@ def set_yscale(self, value, **kwargs):

matplotlib.scale.LogisticTransform : logit transform
"""
# If the scale is being set to log, clip nonposy to prevent headaches
# If the scale is being set to log, mask nonposy to prevent headaches
# around zero
if value.lower() == 'log' and 'nonposy' not in kwargs:
kwargs['nonposy'] = 'clip'
kwargs['nonposy'] = 'mask'

g = self.get_shared_y_axes()
for ax in g.get_siblings(self):
Expand Down
0