Revision: 5410
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5410&view=rev
Author: mdboom
Date: 2008-06-06 05:57:24 -0700 (Fri, 06 Jun 2008)
Log Message:
-----------
Fix polygon closing and provide option not to close (used by
hist(histtype="step"))
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-06 12:07:53 UTC (rev 5409)
+++ trunk/matplotlib/CHANGELOG 2008-06-06 12:57:24 UTC (rev 5410)
@@ -1,3 +1,6 @@
+2008-06-06 Fix closed polygon patch and also provide the option to
+ not close the polygon - MGD
+
2008-06-05 Fix some dpi-changing-related problems with PolyCollection,
as called by Axes.scatter() - MGD
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-06 12:07:53 UTC (rev
5409)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-06 12:57:24 UTC (rev
5410)
@@ -345,12 +345,16 @@
seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
fill=True,
+ closed=closed
)
self.set_patchprops(seg, **kwargs)
ret.append(seg)
- if self.command == 'plot': func = makeline
- else: func = makefill
+ if self.command == 'plot':
+ func = makeline
+ else:
+ closed = kwargs.pop("closed")
+ func = makefill
if multicol:
for j in range(y.shape[1]):
func(x[:,j], y[:,j])
@@ -387,12 +391,16 @@
seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
fill=True,
+ closed=closed
)
self.set_patchprops(seg, **kwargs)
ret.append(seg)
- if self.command == 'plot': func = makeline
- else: func = makefill
+ if self.command == 'plot':
+ func = makeline
+ else:
+ closed = kwargs.pop('closed')
+ func = makefill
if multicol:
for j in range(y.shape[1]):
@@ -4934,6 +4942,8 @@
See examples/fill_between.py for more examples.
+ The closed kwarg will close the polygon when True (default).
+
kwargs control the Polygon properties:
%(Polygon)s
"""
@@ -5809,7 +5819,7 @@
x,y = y,x
elif orientation != 'vertical':
raise ValueError, 'invalid orientation: %s' % orientation
- patches.append( self.fill(x,y) )
+ patches.append( self.fill(x,y,closed=False) )
# adopted from adjust_x/ylim part of the bar method
if orientation == 'horizontal':
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2008-06-06 12:07:53 UTC (rev
5409)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2008-06-06 12:57:24 UTC (rev
5410)
@@ -531,7 +531,7 @@
def __str__(self):
return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0])
- def __init__(self, xy, **kwargs):
+ def __init__(self, xy, closed=True, **kwargs):
"""
xy is a numpy array with shape Nx2
@@ -541,7 +541,7 @@
"""
Patch.__init__(self, **kwargs)
xy = np.asarray(xy, np.float_)
- if len(xy) and xy[0] != xy[-1]:
+ if closed and len(xy) and (xy[0] != xy[-1]).any():
xy = np.concatenate([xy, [xy[0]]])
self._path = Path(xy)
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins