3
3
Connectionstyle Demo
4
4
====================
5
5
6
+ When creating an annotation using `~.Axes.annotate`, the arrow shape can be
7
+ controlled via the *connectionstyle* parameter of *arrowprops*. For further
8
+ details see the description of `.FancyArrowPatch`.
6
9
"""
7
10
8
11
import matplotlib .pyplot as plt
9
12
10
13
11
- fig , axs = plt .subplots (3 , 5 , figsize = (8 , 4.8 ))
12
- x1 , y1 = 0.3 , 0.3
13
- x2 , y2 = 0.7 , 0.7
14
-
15
-
16
- def demo_con_style (ax , connectionstyle , label = None ):
14
+ def demo_con_style (ax , connectionstyle ):
17
15
x1 , y1 = 0.3 , 0.2
18
16
x2 , y2 = 0.8 , 0.6
19
17
20
18
ax .plot ([x1 , x2 ], [y1 , y2 ], "." )
21
19
ax .annotate ("" ,
22
20
xy = (x1 , y1 ), xycoords = 'data' ,
23
21
xytext = (x2 , y2 ), textcoords = 'data' ,
24
- arrowprops = dict (arrowstyle = "->" ,
25
- color = "0.5" ,
22
+ arrowprops = dict (arrowstyle = "->" , color = "0.5" ,
26
23
shrinkA = 5 , shrinkB = 5 ,
27
- patchA = None ,
28
- patchB = None ,
24
+ patchA = None , patchB = None ,
29
25
connectionstyle = connectionstyle ,
30
26
),
31
27
)
@@ -34,6 +30,7 @@ def demo_con_style(ax, connectionstyle, label=None):
34
30
transform = ax .transAxes , ha = "left" , va = "top" )
35
31
36
32
33
+ fig , axs = plt .subplots (3 , 5 , figsize = (8 , 4.8 ))
37
34
demo_con_style (axs [0 , 0 ], "angle3,angleA=90,angleB=0" )
38
35
demo_con_style (axs [1 , 0 ], "angle3,angleA=0,angleB=90" )
39
36
demo_con_style (axs [0 , 1 ], "arc3,rad=0." )
@@ -51,6 +48,20 @@ def demo_con_style(ax, connectionstyle, label=None):
51
48
52
49
for ax in axs .flat :
53
50
ax .set (xlim = (0 , 1 ), ylim = (0 , 1 ), xticks = [], yticks = [], aspect = 1 )
54
- fig .tight_layout (pad = 0 )
51
+ fig .tight_layout (pad = 0.2 )
55
52
56
53
plt .show ()
54
+
55
+ #############################################################################
56
+ #
57
+ # ------------
58
+ #
59
+ # References
60
+ # """"""""""
61
+ #
62
+ # The use of the following functions, methods, classes and modules is shown
63
+ # in this example:
64
+
65
+ import matplotlib
66
+ matplotlib .axes .Axes .annotate
67
+ matplotlib .patches .FancyArrowPatch
0 commit comments