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

Skip to content

Commit 430c133

Browse files
committed
added demo showing how to use curvy paths directly
svn path=/trunk/matplotlib/; revision=5310
1 parent aae8eee commit 430c133

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

examples/api/path_patch_demo.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
import matplotlib.path as mpath
3+
import matplotlib.patches as mpatches
4+
import matplotlib.pyplot as plt
5+
6+
Path = mpath.Path
7+
8+
pathdata = [
9+
(Path.MOVETO, (0, 0)),
10+
(Path.CURVE4, (-1, 0)),
11+
(Path.CURVE4, (-1, 1)),
12+
(Path.CURVE4, (0, 1)),
13+
(Path.LINETO, (2, 1)),
14+
(Path.CURVE4, (3, 1)),
15+
(Path.CURVE4, (3, 0)),
16+
(Path.CURVE4, (2, 0)),
17+
(Path.CLOSEPOLY, (0, 0)),
18+
]
19+
20+
codes, verts = zip(*pathdata)
21+
path = mpath.Path(verts, codes)
22+
23+
patch = mpatches.PathPatch(path, facecolor='green', edgecolor='yellow', alpha=0.5)
24+
25+
fig = plt.figure()
26+
ax = fig.add_subplot(111)
27+
ax.add_patch(patch)
28+
29+
ax.set_xlim(-5,5)
30+
ax.set_ylim(-5,5)
31+
32+
plt.show()
33+
34+

0 commit comments

Comments
 (0)