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

Skip to content

Commit 86fb978

Browse files
committed
added jae-joons fancy arrow and box patch for annotations
svn path=/trunk/matplotlib/; revision=6353
1 parent d687aaa commit 86fb978

5 files changed

Lines changed: 2075 additions & 26 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2008-10-24 Added Jae Joon's fancy arrow, box and annotation
2+
enhancements -- see
3+
examples/pylab_examples/annotation_demo2.py
4+
15
2008-10-23 Autoscaling is now supported with shared axes - EF
26

37
2008-10-23 Fixed exception in dviread that happened with Minion - JKS
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
2+
from matplotlib.pyplot import figure, show
3+
from matplotlib.patches import Ellipse
4+
import numpy as np
5+
6+
if 1:
7+
fig = figure(1,figsize=(8,5))
8+
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-4,3))
9+
10+
t = np.arange(0.0, 5.0, 0.01)
11+
s = np.cos(2*np.pi*t)
12+
line, = ax.plot(t, s, lw=3, color='purple')
13+
14+
ax.annotate('arrowstyle', xy=(0, 1), xycoords='data',
15+
xytext=(-50, 30), textcoords='offset points',
16+
arrowprops=dict(arrowstyle="->")
17+
)
18+
19+
ax.annotate('arc3', xy=(0.5, -1), xycoords='data',
20+
xytext=(-30, -30), textcoords='offset points',
21+
arrowprops=dict(arrowstyle="->",
22+
connectionstyle="arc3,rad=.2")
23+
)
24+
25+
ax.annotate('arc', xy=(1., 1), xycoords='data',
26+
xytext=(-40, 30), textcoords='offset points',
27+
arrowprops=dict(arrowstyle="->",
28+
connectionstyle="arc,angleA=0,armA=30,rad=10"),
29+
)
30+
31+
ax.annotate('arc', xy=(1.5, -1), xycoords='data',
32+
xytext=(-40, -30), textcoords='offset points',
33+
arrowprops=dict(arrowstyle="->",
34+
connectionstyle="arc,angleA=0,armA=20,angleB=-90,armB=15,rad=7"),
35+
)
36+
37+
ax.annotate('angle', xy=(2., 1), xycoords='data',
38+
xytext=(-50, 30), textcoords='offset points',
39+
arrowprops=dict(arrowstyle="->",
40+
connectionstyle="angle,angleA=0,angleB=90,rad=10"),
41+
)
42+
43+
ax.annotate('angle3', xy=(2.5, -1), xycoords='data',
44+
xytext=(-50, -30), textcoords='offset points',
45+
arrowprops=dict(arrowstyle="->",
46+
connectionstyle="angle3,angleA=0,angleB=-90"),
47+
)
48+
49+
50+
ax.annotate('angle', xy=(3., 1), xycoords='data',
51+
xytext=(-50, 30), textcoords='offset points',
52+
bbox=dict(boxstyle="round", fc="0.8"),
53+
arrowprops=dict(arrowstyle="->",
54+
connectionstyle="angle,angleA=0,angleB=90,rad=10"),
55+
)
56+
57+
ax.annotate('angle', xy=(3.5, -1), xycoords='data',
58+
xytext=(-70, -60), textcoords='offset points',
59+
size=20,
60+
bbox=dict(boxstyle="round4,pad=.5", fc="0.8"),
61+
arrowprops=dict(arrowstyle="->",
62+
connectionstyle="angle,angleA=0,angleB=-90,rad=10"),
63+
)
64+
65+
ax.annotate('angle', xy=(4., 1), xycoords='data',
66+
xytext=(-50, 30), textcoords='offset points',
67+
bbox=dict(boxstyle="round", fc="0.8"),
68+
arrowprops=dict(arrowstyle="->",
69+
shrinkA=0, shrinkB=10,
70+
connectionstyle="angle,angleA=0,angleB=90,rad=10"),
71+
)
72+
73+
74+
75+
fig.savefig('annotation_connection')
76+
77+
78+
if 1:
79+
fig = figure(2)
80+
fig.clf()
81+
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-5,3))
82+
83+
el = Ellipse((2, -1), 0.5, 0.5)
84+
ax.add_patch(el)
85+
86+
ax.annotate('$->$', xy=(2., -1), xycoords='data',
87+
xytext=(-150, -140), textcoords='offset points',
88+
bbox=dict(boxstyle="round", fc="0.8"),
89+
arrowprops=dict(arrowstyle="->",
90+
patchB=el,
91+
connectionstyle="angle,angleA=90,angleB=0,rad=10"),
92+
)
93+
94+
ax.annotate('fancy', xy=(2., -1), xycoords='data',
95+
xytext=(-100, 60), textcoords='offset points',
96+
size=20,
97+
#bbox=dict(boxstyle="round", fc="0.8"),
98+
arrowprops=dict(arrowstyle="fancy",
99+
fc="0.6", ec="none",
100+
patchB=el,
101+
connectionstyle="angle3,angleA=0,angleB=-90"),
102+
)
103+
104+
ax.annotate('simple', xy=(2., -1), xycoords='data',
105+
xytext=(100, 60), textcoords='offset points',
106+
size=20,
107+
#bbox=dict(boxstyle="round", fc="0.8"),
108+
arrowprops=dict(arrowstyle="simple",
109+
fc="0.6", ec="none",
110+
patchB=el,
111+
connectionstyle="arc3,rad=0.3"),
112+
)
113+
114+
ax.annotate('wedge', xy=(2., -1), xycoords='data',
115+
xytext=(-100, -100), textcoords='offset points',
116+
size=20,
117+
#bbox=dict(boxstyle="round", fc="0.8"),
118+
arrowprops=dict(arrowstyle="wedge,tail_width=0.7",
119+
fc="0.6", ec="none",
120+
patchB=el,
121+
connectionstyle="arc3,rad=-0.3"),
122+
)
123+
124+
125+
ann = ax.annotate('wedge', xy=(2., -1), xycoords='data',
126+
xytext=(0, -45), textcoords='offset points',
127+
size=20,
128+
bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec=(1., .5, .5)),
129+
arrowprops=dict(arrowstyle="wedge,tail_width=1.",
130+
fc=(1.0, 0.7, 0.7), ec=(1., .5, .5),
131+
patchA=None,
132+
patchB=el,
133+
relpos=(0.2, 0.8),
134+
connectionstyle="arc3,rad=-0.1"),
135+
)
136+
137+
ann = ax.annotate('wedge', xy=(2., -1), xycoords='data',
138+
xytext=(35, 0), textcoords='offset points',
139+
size=20, va="center",
140+
bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec="none"),
141+
arrowprops=dict(arrowstyle="wedge,tail_width=1.",
142+
fc=(1.0, 0.7, 0.7), ec="none",
143+
patchA=None,
144+
patchB=el,
145+
relpos=(0.2, 0.5),
146+
)
147+
)
148+
149+
fig.savefig('annotation_arrowstyle')
150+
151+
show()

0 commit comments

Comments
 (0)