diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index c6309b5ab9df..33f348d646d4 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -17,6 +17,7 @@ import matplotlib.colors as mcolors import matplotlib.lines as mlines import matplotlib.patches as mpatches +import matplotlib.path as mpath import matplotlib.artist as martist import matplotlib.transforms as mtransforms import matplotlib.ticker as mticker @@ -2094,7 +2095,8 @@ def _update_patch_limits(self, patch): if (isinstance(patch, mpatches.Rectangle) and ((not patch.get_width()) and (not patch.get_height()))): return - vertices = patch.get_path().vertices + vertices = patch.get_path().\ + vertices[patch.get_path().codes != mpath.Path.CLOSEPOLY] if vertices.size > 0: xys = patch.get_patch_transform().transform(vertices) if patch.get_data_transform() != self.transData: diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 56f45518c340..1ff1a857da41 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -34,6 +34,8 @@ assert_allclose, assert_array_equal, assert_array_almost_equal) from matplotlib import rc_context from matplotlib.cbook import MatplotlibDeprecationWarning +import sys +import math # Note: Some test cases are run twice: once normally and once with labeled data # These two must be defined in the same test function or need to have @@ -6856,3 +6858,15 @@ def test_ylabel_ha_with_position(ha): ax.set_ylabel("test", y=1, ha=ha) ax.yaxis.set_label_position("right") assert ax.yaxis.get_label().get_ha() == ha + + +def test_patch_bounds(): + fig, ax = plt.subplots() + tol = 16*sys.float_info.epsilon + ax.add_patch(mpatches.Wedge((0, -1), 1.05, 60, 120, 0.1)) + bounds = ax.dataLim.bounds + bot = 1.9*math.sin(15*math.pi/180)**2 + assert abs(bounds[0]+0.525) < tol and \ + abs(bounds[1]+(bot+0.05)) < tol and \ + abs(bounds[2]-1.05) < tol and \ + abs(bounds[3]-(bot+0.1)) < tol