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

Skip to content

Commit 04e59e0

Browse files
committed
add new arrow style (a line + filled triangles)
svn path=/trunk/matplotlib/; revision=6664
1 parent ffcd8a9 commit 04e59e0

5 files changed

Lines changed: 208 additions & 54 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-12-18 add new arrow style, a line + filled triangles. -JJL
2+
13
2008-12-18 Fix bug where a line with NULL data limits prevents
24
subsequent data limits from calculating correctly - MGD
35

examples/pylab_examples/fancyarrow_demo.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33

44
styles = mpatches.ArrowStyle.get_styles()
55

6-
figheight = (len(styles)+.5)
7-
fig1 = plt.figure(1, (4, figheight))
8-
fontsize = 0.3 * fig1.dpi
6+
ncol=2
7+
nrow = len(styles) // ncol + 1
8+
figheight = (nrow+0.5)
9+
fig1 = plt.figure(1, (4.*ncol/1.5, figheight/1.5))
10+
fontsize = 0.2 * 70
911

1012

1113
ax = fig1.add_axes([0, 0, 1, 1], frameon=False, aspect=1.)
1214

13-
ax.set_xlim(0, 4)
15+
ax.set_xlim(0, 4*ncol)
1416
ax.set_ylim(0, figheight)
1517

1618
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
17-
y = (float(len(styles)) -0.25 - i) # /figheight
18-
p = mpatches.Circle((3.2, y), 0.2, fc="w")
19+
x = 3.2 + (i//nrow)*4
20+
y = (figheight - 0.7 - i%nrow) # /figheight
21+
p = mpatches.Circle((x, y), 0.2, fc="w")
1922
ax.add_patch(p)
2023

21-
ax.annotate(stylename, (3.2, y),
22-
(2., y),
24+
ax.annotate(stylename, (x, y),
25+
(x-1.2, y),
2326
#xycoords="figure fraction", textcoords="figure fraction",
2427
ha="right", va="center",
2528
size=fontsize,

examples/pylab_examples/fancybox_demo2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
styles = mpatch.BoxStyle.get_styles()
55

66
figheight = (len(styles)+.5)
7-
fig1 = plt.figure(1, (4, figheight))
8-
fontsize = 0.4 * fig1.dpi
7+
fig1 = plt.figure(1, (4/1.5, figheight/1.5))
8+
fontsize = 0.3 * 72
99

1010
for i, (stylename, styleclass) in enumerate(styles.items()):
1111
fig1.text(0.5, (float(len(styles)) - 0.5 - i)/figheight, stylename,
@@ -15,3 +15,4 @@
1515
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
1616
plt.draw()
1717
plt.show()
18+

lib/matplotlib/bezier.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,38 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
468468

469469

470470

471+
def make_path_regular(p):
472+
"""
473+
fill in the codes if None.
474+
"""
475+
c = p.codes
476+
if c is None:
477+
c = np.empty(p.vertices.shape, "i")
478+
c.fill(Path.LINETO)
479+
c[0] = Path.MOVETO
480+
481+
return Path(p.vertices, c)
482+
else:
483+
return p
484+
485+
def concatenate_paths(paths):
486+
"""
487+
concatenate list of paths into a single path.
488+
"""
489+
490+
vertices = []
491+
codes = []
492+
for p in paths:
493+
p = make_path_regular(p)
494+
vertices.append(p.vertices)
495+
codes.append(p.codes)
496+
497+
_path = Path(np.concatenate(vertices),
498+
np.concatenate(codes))
499+
return _path
500+
501+
502+
471503
if 0:
472504
path = Path([(0, 0), (1, 0), (2, 2)],
473505
[Path.MOVETO, Path.CURVE3, Path.CURVE3])
@@ -476,3 +508,4 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
476508
ax = gca()
477509

478510

511+

0 commit comments

Comments
 (0)