Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7898bbb

Browse files
committed
Make nonposy='clip' default for log scale y-axes
1 parent 954b752 commit 7898bbb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,10 @@ def set_xscale(self, value, **kwargs):
25442544
Different kwargs are accepted, depending on the scale:
25452545
%(scale_docs)s
25462546
"""
2547+
# If the scale is being set to log, clip nonposx to prevent headaches
2548+
# around zero
2549+
if value.lower() == 'log' and 'nonposx' not in kwargs.keys():
2550+
kwargs['nonposx'] = 'clip'
25472551
self.xaxis._set_scale(value, **kwargs)
25482552
self.autoscale_view(scaley=False)
25492553
self._update_transScale()
@@ -2770,6 +2774,10 @@ def set_yscale(self, value, **kwargs):
27702774
Different kwargs are accepted, depending on the scale:
27712775
%(scale_docs)s
27722776
"""
2777+
# If the scale is being set to log, clip nonposy to prevent headaches
2778+
# around zero
2779+
if value.lower() == 'log' and 'nonposy' not in kwargs.keys():
2780+
kwargs['nonposy'] = 'clip'
27732781
self.yaxis._set_scale(value, **kwargs)
27742782
self.autoscale_view(scalex=False)
27752783
self._update_transScale()

0 commit comments

Comments
 (0)