FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/doc/users/plotting/examples/annotate_explain.py at master · feisuo/matplotlib · GitHub
feisuo
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
doc
/
users
/
plotting
/
examples
/
annotate_explain.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
103 lines (83 loc) · 2.92 KB
Breadcrumbs
matplotlib
/
doc
/
users
/
plotting
/
examples
/
annotate_explain.py
Copy path
File metadata and controls
103 lines (83 loc) · 2.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import
matplotlib
.
pyplot
as
plt
import
matplotlib
.
patches
as
mpatches
x1
,
y1
=
0.3
,
0.3
x2
,
y2
=
0.7
,
0.7
fig
=
plt
.
figure
(
1
,
figsize
=
(
8
,
3
))
fig
.
clf
()
from
mpl_toolkits
.
axes_grid1
.
axes_grid
import
AxesGrid
from
matplotlib
.
offsetbox
import
AnchoredText
#from matplotlib.font_manager import FontProperties
def
add_at
(
ax
,
t
,
loc
=
2
):
fp
=
dict
(
size
=
10
)
_at
=
AnchoredText
(
t
,
loc
=
loc
,
prop
=
fp
)
ax
.
add_artist
(
_at
)
return
_at
grid
=
AxesGrid
(
fig
,
111
, (
1
,
4
),
label_mode
=
"1"
,
share_all
=
True
)
grid
[
0
].
set_autoscale_on
(
False
)
ax
=
grid
[
0
]
ax
.
plot
([
x1
,
x2
], [
y1
,
y2
],
"."
)
el
=
mpatches
.
Ellipse
((
x1
,
y1
),
0.3
,
0.4
,
angle
=
30
,
alpha
=
0.2
)
ax
.
add_artist
(
el
)
ax
.
annotate
(
""
,
xy
=
(
x1
,
y1
),
xycoords
=
'data'
,
xytext
=
(
x2
,
y2
),
textcoords
=
'data'
,
arrowprops
=
dict
(
arrowstyle
=
"-"
,
#linestyle="dashed",
color
=
"0.5"
,
patchB
=
None
,
shrinkB
=
0
,
connectionstyle
=
"arc3,rad=0.3"
,
),
)
add_at
(
ax
,
"connect"
,
loc
=
2
)
ax
=
grid
[
1
]
ax
.
plot
([
x1
,
x2
], [
y1
,
y2
],
"."
)
el
=
mpatches
.
Ellipse
((
x1
,
y1
),
0.3
,
0.4
,
angle
=
30
,
alpha
=
0.2
)
ax
.
add_artist
(
el
)
ax
.
annotate
(
""
,
xy
=
(
x1
,
y1
),
xycoords
=
'data'
,
xytext
=
(
x2
,
y2
),
textcoords
=
'data'
,
arrowprops
=
dict
(
arrowstyle
=
"-"
,
#linestyle="dashed",
color
=
"0.5"
,
patchB
=
el
,
shrinkB
=
0
,
connectionstyle
=
"arc3,rad=0.3"
,
),
)
add_at
(
ax
,
"clip"
,
loc
=
2
)
ax
=
grid
[
2
]
ax
.
plot
([
x1
,
x2
], [
y1
,
y2
],
"."
)
el
=
mpatches
.
Ellipse
((
x1
,
y1
),
0.3
,
0.4
,
angle
=
30
,
alpha
=
0.2
)
ax
.
add_artist
(
el
)
ax
.
annotate
(
""
,
xy
=
(
x1
,
y1
),
xycoords
=
'data'
,
xytext
=
(
x2
,
y2
),
textcoords
=
'data'
,
arrowprops
=
dict
(
arrowstyle
=
"-"
,
#linestyle="dashed",
color
=
"0.5"
,
patchB
=
el
,
shrinkB
=
5
,
connectionstyle
=
"arc3,rad=0.3"
,
),
)
add_at
(
ax
,
"shrink"
,
loc
=
2
)
ax
=
grid
[
3
]
ax
.
plot
([
x1
,
x2
], [
y1
,
y2
],
"."
)
el
=
mpatches
.
Ellipse
((
x1
,
y1
),
0.3
,
0.4
,
angle
=
30
,
alpha
=
0.2
)
ax
.
add_artist
(
el
)
ax
.
annotate
(
""
,
xy
=
(
x1
,
y1
),
xycoords
=
'data'
,
xytext
=
(
x2
,
y2
),
textcoords
=
'data'
,
arrowprops
=
dict
(
arrowstyle
=
"fancy"
,
#linestyle="dashed",
color
=
"0.5"
,
patchB
=
el
,
shrinkB
=
5
,
connectionstyle
=
"arc3,rad=0.3"
,
),
)
add_at
(
ax
,
"mutate"
,
loc
=
2
)
grid
[
0
].
set_xlim
(
0
,
1
)
grid
[
0
].
set_ylim
(
0
,
1
)
grid
[
0
].
axis
[
"bottom"
].
toggle
(
ticklabels
=
False
)
grid
[
0
].
axis
[
"left"
].
toggle
(
ticklabels
=
False
)
fig
.
subplots_adjust
(
left
=
0.05
,
right
=
0.95
,
bottom
=
0.05
,
top
=
0.95
)
plt
.
draw
()
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL