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

Skip to content

Commit 83f0f03

Browse files
committed
Added get/set_closed to Polygon
svn path=/trunk/matplotlib/; revision=5608
1 parent 63eae2a commit 83f0f03

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-06-20 Added set/get_closed method to Polygon; fixes error
2+
in hist - MM
3+
14
2008-06-19 Use relative font sizes (e.g. 'medium' and 'large') in
25
rcsetup.py and matplotlibrc.template so that text will
36
be scaled by default when changing rcParams['font.size'] -

lib/matplotlib/patches.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,28 @@ def __init__(self, xy, closed=True, **kwargs):
558558
"""
559559
Patch.__init__(self, **kwargs)
560560
xy = np.asarray(xy, np.float_)
561-
if closed and len(xy) and (xy[0] != xy[-1]).any():
562-
xy = np.concatenate([xy, [xy[0]]])
563561
self._path = Path(xy)
562+
self.set_closed(closed)
563+
564564
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
565565

566566
def get_path(self):
567567
return self._path
568568

569+
def get_closed(self):
570+
return self._closed
571+
572+
def set_closed(self, closed):
573+
self._closed = closed
574+
xy = self._get_xy()
575+
if closed:
576+
if len(xy) and (xy[0] != xy[-1]).any():
577+
xy = np.concatenate([xy, [xy[0]]])
578+
else:
579+
if len(xy)>2 and (xy[0]==xy[-1]).all():
580+
xy = xy[0:-2]
581+
self._set_xy(xy)
582+
569583
def _get_xy(self):
570584
return self._path.vertices
571585
def _set_xy(self, vertices):

0 commit comments

Comments
 (0)