From a4442505b4cb28cc2b87da6eabb518985607600d Mon Sep 17 00:00:00 2001 From: kskod Date: Wed, 16 Mar 2016 17:58:13 -0400 Subject: [PATCH 1/4] fixed issue #5456 --- lib/matplotlib/tight_layout.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 18a19370a092..3b2d6bb33030 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -169,19 +169,34 @@ def auto_adjust_subplotpars(fig, renderer, if not margin_left: margin_left = max([sum(s) for s in hspaces[::cols + 1]] + [0]) margin_left += pad_inches / fig_width_inch + # bugfix for bug-#5456 + # simple check for the error + if margin_left > 0.5: + margin_left = 0.05 if not margin_right: margin_right = max([sum(s) for s in hspaces[cols::cols + 1]] + [0]) margin_right += pad_inches / fig_width_inch + # bugfix for bug-#5456 + # simple check for the error + if margin_right > 0.5: + margin_right = 0.05 if not margin_top: margin_top = max([sum(s) for s in vspaces[:cols]] + [0]) margin_top += pad_inches / fig_height_inch + # bugfix for bug-#5456 + if margin_top > 0.5: + margin_top = 0.05 if not margin_bottom: margin_bottom = max([sum(s) for s in vspaces[-cols:]] + [0]) margin_bottom += pad_inches / fig_height_inch + # bugfix for bug-#5456 + if margin_bottom > 0.5: + margin_bottom = 0.05 + kwargs = dict(left=margin_left, right=1 - margin_right, bottom=margin_bottom, From 2a02dfcff34714cd8e6987233fe4c45cb1f6ba07 Mon Sep 17 00:00:00 2001 From: kskod Date: Wed, 16 Mar 2016 18:12:39 -0400 Subject: [PATCH 2/4] fixed bug for issue #4414 --- lib/matplotlib/axes/_axes.py | 42 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index ffc794ee4e60..c388d3fe8f09 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3147,16 +3147,16 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None, If True produces boxes with the Patch artist showmeans : bool, default = False - If True, will toggle one the rendering of the means + If True, will toggle on the rendering of the means showcaps : bool, default = True - If True, will toggle one the rendering of the caps + If True, will toggle on the rendering of the caps showbox : bool, default = True - If True, will toggle one the rendering of box + If True, will toggle on the rendering of the box showfliers : bool, default = True - If True, will toggle one the rendering of the fliers + If True, will toggle on the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -3412,16 +3412,16 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True, If `True`, will produce a notched box plot showmeans : bool, default = False - If `True`, will toggle one the rendering of the means + If `True`, will toggle on the rendering of the means showcaps : bool, default = True - If `True`, will toggle one the rendering of the caps + If `True`, will toggle on the rendering of the caps showbox : bool, default = True - If `True`, will toggle one the rendering of box + If `True`, will toggle on the rendering of the box showfliers : bool, default = True - If `True`, will toggle one the rendering of the fliers + If `True`, will toggle on the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -6225,7 +6225,6 @@ def _normalize_input(inp, ename='input'): # we return patches, so put it back in the expected order patches.reverse() - # adopted from adjust_x/ylim part of the bar method if orientation == 'horizontal': xmin0 = max(_saved_bounds[0]*0.9, minimum) xmax = self.dataLim.intervalx[1] @@ -6237,16 +6236,23 @@ def _normalize_input(inp, ename='input'): xmin = min(xmin0, xmin) self.dataLim.intervalx = (xmin, xmax) elif orientation == 'vertical': - ymin0 = max(_saved_bounds[1]*0.9, minimum) - ymax = self.dataLim.intervaly[1] - for m in n: - if np.sum(m) > 0: # make sure there are counts - ymin = np.amin(m[m != 0]) - # filter out the 0 height bins - ymin = max(ymin*0.9, minimum) if not input_empty else minimum - ymin = min(ymin0, ymin) - self.dataLim.intervaly = (ymin, ymax) + # If norm, autoscale axis + # fixed bug for #4414 + if normed: + self.set_autoscaley_on(True) + else: + ymin0 = max(_saved_bounds[1]*0.9, minimum) + ymax = self.dataLim.intervaly[1] + + for m in n: + if np.sum(m) > 0: # make sure there are counts + ymin = np.amin(m[m != 0]) + # filter out the 0 height bins + ymin = max(ymin*0.9, minimum) if not input_empty else minimum + ymin = min(ymin0, ymin) + self.dataLim.intervaly = (ymin, ymax) + if label is None: labels = [None] From 7902d5db79430f4df7025ebe8fc7cf1ac3eef81b Mon Sep 17 00:00:00 2001 From: kskod Date: Wed, 16 Mar 2016 18:19:29 -0400 Subject: [PATCH 3/4] Revert "fixed bug for issue #4414" This reverts commit 2a02dfcff34714cd8e6987233fe4c45cb1f6ba07. --- lib/matplotlib/axes/_axes.py | 42 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c388d3fe8f09..ffc794ee4e60 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3147,16 +3147,16 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None, If True produces boxes with the Patch artist showmeans : bool, default = False - If True, will toggle on the rendering of the means + If True, will toggle one the rendering of the means showcaps : bool, default = True - If True, will toggle on the rendering of the caps + If True, will toggle one the rendering of the caps showbox : bool, default = True - If True, will toggle on the rendering of the box + If True, will toggle one the rendering of box showfliers : bool, default = True - If True, will toggle on the rendering of the fliers + If True, will toggle one the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -3412,16 +3412,16 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True, If `True`, will produce a notched box plot showmeans : bool, default = False - If `True`, will toggle on the rendering of the means + If `True`, will toggle one the rendering of the means showcaps : bool, default = True - If `True`, will toggle on the rendering of the caps + If `True`, will toggle one the rendering of the caps showbox : bool, default = True - If `True`, will toggle on the rendering of the box + If `True`, will toggle one the rendering of box showfliers : bool, default = True - If `True`, will toggle on the rendering of the fliers + If `True`, will toggle one the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -6225,6 +6225,7 @@ def _normalize_input(inp, ename='input'): # we return patches, so put it back in the expected order patches.reverse() + # adopted from adjust_x/ylim part of the bar method if orientation == 'horizontal': xmin0 = max(_saved_bounds[0]*0.9, minimum) xmax = self.dataLim.intervalx[1] @@ -6236,23 +6237,16 @@ def _normalize_input(inp, ename='input'): xmin = min(xmin0, xmin) self.dataLim.intervalx = (xmin, xmax) elif orientation == 'vertical': + ymin0 = max(_saved_bounds[1]*0.9, minimum) + ymax = self.dataLim.intervaly[1] - # If norm, autoscale axis - # fixed bug for #4414 - if normed: - self.set_autoscaley_on(True) - else: - ymin0 = max(_saved_bounds[1]*0.9, minimum) - ymax = self.dataLim.intervaly[1] - - for m in n: - if np.sum(m) > 0: # make sure there are counts - ymin = np.amin(m[m != 0]) - # filter out the 0 height bins - ymin = max(ymin*0.9, minimum) if not input_empty else minimum - ymin = min(ymin0, ymin) - self.dataLim.intervaly = (ymin, ymax) - + for m in n: + if np.sum(m) > 0: # make sure there are counts + ymin = np.amin(m[m != 0]) + # filter out the 0 height bins + ymin = max(ymin*0.9, minimum) if not input_empty else minimum + ymin = min(ymin0, ymin) + self.dataLim.intervaly = (ymin, ymax) if label is None: labels = [None] From e65c781d4a22e8ddc6cfbee4189c53464de2a68e Mon Sep 17 00:00:00 2001 From: kskod Date: Wed, 16 Mar 2016 18:23:13 -0400 Subject: [PATCH 4/4] fixed bug for #4414 --- lib/matplotlib/axes/_axes.py | 41 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index ffc794ee4e60..19c5a3a76a99 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3147,16 +3147,16 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None, If True produces boxes with the Patch artist showmeans : bool, default = False - If True, will toggle one the rendering of the means + If True, will toggle on the rendering of the means showcaps : bool, default = True - If True, will toggle one the rendering of the caps + If True, will toggle on the rendering of the caps showbox : bool, default = True - If True, will toggle one the rendering of box + If True, will toggle on the rendering of the box showfliers : bool, default = True - If True, will toggle one the rendering of the fliers + If True, will toggle on the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -3412,16 +3412,16 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True, If `True`, will produce a notched box plot showmeans : bool, default = False - If `True`, will toggle one the rendering of the means + If `True`, will toggle on the rendering of the means showcaps : bool, default = True - If `True`, will toggle one the rendering of the caps + If `True`, will toggle on the rendering of the caps showbox : bool, default = True - If `True`, will toggle one the rendering of box + If `True`, will toggle on the rendering of the box showfliers : bool, default = True - If `True`, will toggle one the rendering of the fliers + If `True`, will toggle on the rendering of the fliers boxprops : dict or None (default) If provided, will set the plotting style of the boxes @@ -6225,7 +6225,6 @@ def _normalize_input(inp, ename='input'): # we return patches, so put it back in the expected order patches.reverse() - # adopted from adjust_x/ylim part of the bar method if orientation == 'horizontal': xmin0 = max(_saved_bounds[0]*0.9, minimum) xmax = self.dataLim.intervalx[1] @@ -6237,16 +6236,22 @@ def _normalize_input(inp, ename='input'): xmin = min(xmin0, xmin) self.dataLim.intervalx = (xmin, xmax) elif orientation == 'vertical': - ymin0 = max(_saved_bounds[1]*0.9, minimum) - ymax = self.dataLim.intervaly[1] - for m in n: - if np.sum(m) > 0: # make sure there are counts - ymin = np.amin(m[m != 0]) - # filter out the 0 height bins - ymin = max(ymin*0.9, minimum) if not input_empty else minimum - ymin = min(ymin0, ymin) - self.dataLim.intervaly = (ymin, ymax) + # If norm, autoscale axis + if normed: + self.set_autoscaley_on(True) + else: + ymin0 = max(_saved_bounds[1]*0.9, minimum) + ymax = self.dataLim.intervaly[1] + + for m in n: + if np.sum(m) > 0: # make sure there are counts + ymin = np.amin(m[m != 0]) + # filter out the 0 height bins + ymin = max(ymin*0.9, minimum) if not input_empty else minimum + ymin = min(ymin0, ymin) + self.dataLim.intervaly = (ymin, ymax) + if label is None: labels = [None]