Revision: 7021
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7021&view=rev
Author: jdh2358
Date: 2009-04-01 20:44:27 +0000 (Wed, 01 Apr 2009)
Log Message:
-----------
added compound path demo
Added Paths:
-----------
trunk/matplotlib/examples/api/complex_path.py
Added: trunk/matplotlib/examples/api/complex_path.py
===================================================================
--- trunk/matplotlib/examples/api/complex_path.py
(rev 0)
+++ trunk/matplotlib/examples/api/complex_path.py 2009-04-01 20:44:27 UTC
(rev 7021)
@@ -0,0 +1,35 @@
+"""
+Make a compund path -- in this case two simple polygons, a rectangle
+and a triangle. Use CLOSEOPOLY and MOVETO for the different parts of
+the compound path
+"""
+import numpy as np
+from matplotlib.path import Path
+from matplotlib.patches import PathPatch
+import matplotlib.pyplot as plt
+
+
+vertices = []
+codes = []
+
+codes = [Path.MOVETO] + [Path.LINETO]*3 + [Path.CLOSEPOLY]
+vertices = [(1,1), (1,2), (2, 2), (2, 1), (0,0)]
+
+codes += [Path.MOVETO] + [Path.LINETO]*2 + [Path.CLOSEPOLY]
+vertices += [(4,4), (5,5), (5, 4), (0,0)]
+
+vertices = np.array(vertices, float)
+path = Path(vertices, codes)
+
+pathpatch = PathPatch(path, facecolor='red', edgecolor='green')
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.add_patch(pathpatch)
+ax.set_title('A compound path')
+
+ax.dataLim.update_from_data_xy(vertices)
+ax.autoscale_view()
+
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins