From 7898bbbc21e7cb83588e45681511c3dca786a0f5 Mon Sep 17 00:00:00 2001 From: Damon McDougall Date: Fri, 5 Jul 2013 21:53:40 -0400 Subject: [PATCH] Make nonposy='clip' default for log scale y-axes --- lib/matplotlib/axes/_base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 99f09156a006..4201c78fda23 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2544,6 +2544,10 @@ def set_xscale(self, value, **kwargs): Different kwargs are accepted, depending on the scale: %(scale_docs)s """ + # If the scale is being set to log, clip nonposx to prevent headaches + # around zero + if value.lower() == 'log' and 'nonposx' not in kwargs.keys(): + kwargs['nonposx'] = 'clip' self.xaxis._set_scale(value, **kwargs) self.autoscale_view(scaley=False) self._update_transScale() @@ -2770,6 +2774,10 @@ def set_yscale(self, value, **kwargs): Different kwargs are accepted, depending on the scale: %(scale_docs)s """ + # If the scale is being set to log, clip nonposy to prevent headaches + # around zero + if value.lower() == 'log' and 'nonposy' not in kwargs.keys(): + kwargs['nonposy'] = 'clip' self.yaxis._set_scale(value, **kwargs) self.autoscale_view(scalex=False) self._update_transScale()