text()
will place textat an arbitrary position on the Axes. A common use case of text is toannotate some feature of the plot, and theannotate()
method provides helper functionalityto make annotations easy. In an annotation, there are two points toconsider: the location being annotated represented by the argumentxy
and the location of the text xytext
. Both of thesearguments are (x,y)
tuples.xy
(arrow tip) and xytext
locations(text location) are in data coordinates. There are a variety of othercoordinate systems one can choose -- you can specify the coordinatesystem of xy
and xytext
with one of the following strings forxycoords
and textcoords
(default is 'data')argument | coordinate system |
---|---|
'figure points' | points from the lower left corner of the figure |
'figure pixels' | pixels from the lower left corner of the figure |
'figure fraction' | 0,0 is lower left of figure and 1,1 is upper right |
'axes points' | points from lower left corner of axes |
'axes pixels' | pixels from lower left corner of axes |
'axes fraction' | 0,0 is lower left of axes and 1,1 is upper right |
'data' | use the axes data coordinate system |
arrowprops
.arrowprops key | description |
---|---|
width | the width of the arrow in points |
frac | the fraction of the arrow length occupied by the head |
headwidth | the width of the base of the arrow head in points |
shrink | move the tip and base some percent away fromthe annotated point and text |
**kwargs | any key for matplotlib.patches.Polygon ,e.g., facecolor |
xy
point is in native coordinates(xycoords
defaults to 'data'). For a polar axes, this is in(theta, radius) space. The text in this example is placed in thefractional figure coordinate system. matplotlib.text.Text
keyword args like horizontalalignment
, verticalalignment
andfontsize
are passed from annotate
to theText
instance.text()
and annotate()
!