From: <mme...@us...> - 2008-06-20 11:55:01
|
Revision: 5608 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5608&view=rev Author: mmetz_bn Date: 2008-06-20 04:54:55 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Added get/set_closed to Polygon Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-06-20 10:46:12 UTC (rev 5607) +++ trunk/matplotlib/CHANGELOG 2008-06-20 11:54:55 UTC (rev 5608) @@ -1,3 +1,6 @@ +2008-06-20 Added set/get_closed method to Polygon; fixes error + in hist - MM + 2008-06-19 Use relative font sizes (e.g. 'medium' and 'large') in rcsetup.py and matplotlibrc.template so that text will be scaled by default when changing rcParams['font.size'] - Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008-06-20 10:46:12 UTC (rev 5607) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008-06-20 11:54:55 UTC (rev 5608) @@ -558,14 +558,28 @@ """ Patch.__init__(self, **kwargs) xy = np.asarray(xy, np.float_) - if closed and len(xy) and (xy[0] != xy[-1]).any(): - xy = np.concatenate([xy, [xy[0]]]) self._path = Path(xy) + self.set_closed(closed) + __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): return self._path + def get_closed(self): + return self._closed + + def set_closed(self, closed): + self._closed = closed + xy = self._get_xy() + if closed: + if len(xy) and (xy[0] != xy[-1]).any(): + xy = np.concatenate([xy, [xy[0]]]) + else: + if len(xy)>2 and (xy[0]==xy[-1]).all(): + xy = xy[0:-2] + self._set_xy(xy) + def _get_xy(self): return self._path.vertices def _set_xy(self, vertices): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |