diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 5cd05bc167bb..e6f6f6fefa71 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -187,6 +187,11 @@ def get_grid_positions(self, fig): fig_tops, fig_bottoms = (top - cell_hs).reshape((-1, 2)).T fig_lefts, fig_rights = (left + cell_ws).reshape((-1, 2)).T + + # avoid floating-point precision where A + (B - A) does not equal B + fig_bottoms[-1] = bottom + fig_rights[-1] = right + return fig_bottoms, fig_tops, fig_lefts, fig_rights @staticmethod