matplotlib.patches.FancyArrowPatch#
- class matplotlib.patches.FancyArrowPatch(posA=None, posB=None, *, path=None, arrowstyle='simple', connectionstyle='arc3', patchA=None, patchB=None, shrinkA=2, shrinkB=2, mutation_scale=1, mutation_aspect=1, **kwargs)[source]#
Bases:
PatchA fancy arrow patch.
It draws an arrow using the
ArrowStyle. It is primarily used by theannotatemethod. For most purposes, use the annotate method for drawing arrows.The head and tail positions are fixed at the specified start and end points of the arrow, but the size and shape (in display coordinates) of the arrow does not change when the axis is moved or zoomed.
Defining the arrow position and path
There are two ways to define the arrow position and path:
Start, end and connection: The typical approach is to define the start and end points of the arrow using posA and posB. The curve between these two can further be configured using connectionstyle.
If given, the arrow curve is clipped by patchA and patchB, allowing it to start/end at the border of these patches. Additionally, the arrow curve can be shortened by shrinkA and shrinkB to create a margin between start/end (after possible clipping) and the drawn arrow.
path: Alternatively if path is provided, an arrow is drawn along this Path. In this case, connectionstyle, patchA, patchB, shrinkA, and shrinkB are ignored.
Styling
The arrowstyle defines the styling of the arrow head, tail and shaft. The resulting arrows can be styled further by setting the
Patchproperties such as linewidth, color, facecolor, edgecolor etc. via keyword arguments.- Parameters:
- posA, posB(float, float), optional
(x, y) coordinates of start and end point of the arrow. The actually drawn start and end positions may be modified through patchA, patchB, shrinkA, and shrinkB.
posA, posB are exclusive of path.
- path
Path, optional If provided, an arrow is drawn along this path and patchA, patchB, shrinkA, and shrinkB are ignored.
path is exclusive of posA, posB.
- arrowstylestr or
ArrowStyle, default: 'simple' The styling of arrow head, tail and shaft. This can be
ArrowStyleor one of its subclassesThe shorthand string name (e.g. "->") as given in the table below, optionally containing a comma-separated list of style parameters, e.g. "->, head_length=10, head_width=5".
The style parameters are scaled by mutation_scale.
The following arrow styles are available. See also Annotation arrow style reference.
Class
Name
Parameters
Curve
-None
CurveA
<-head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveB
->head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveAB
<->head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledA
<|-head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledB
-|>head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledAB
<|-|>head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
BracketA
]-widthA=1.0, lengthA=0.2, angleA=0
BracketB
-[widthB=1.0, lengthB=0.2, angleB=0
BracketAB
]-[widthA=1.0, lengthA=0.2, angleA=0, widthB=1.0, lengthB=0.2, angleB=0
BarAB
|-|widthA=1.0, angleA=0, widthB=1.0, angleB=0
BracketCurve
]->widthA=1.0, lengthA=0.2, angleA=None
CurveBracket
<-[widthB=1.0, lengthB=0.2, angleB=None
Simple
simplehead_length=0.5, head_width=0.5, tail_width=0.2
Fancy
fancyhead_length=0.4, head_width=0.4, tail_width=0.4
Wedge
wedgetail_width=0.3, shrink_factor=0.5
Only the styles
<|-,-|>,<|-|>simple,fancyandwedgecontain closed paths and can be filled.- connectionstylestr or
ConnectionStyleor None, optional, default: 'arc3' ConnectionStylewith which posA and posB are connected. This can beConnectionStyleor one of its subclassesThe shorthand string name as given in the table below, e.g. "arc3".
Class
Name
Parameters
Arc3
arc3rad=0.0
Angle3
angle3angleA=90, angleB=0
Angle
angleangleA=90, angleB=0, rad=0.0
Arc
arcangleA=0, angleB=0, armA=None, armB=None, rad=0.0
Bar
bararmA=0.0, armB=0.0, fraction=0.3, angle=None
Ignored if path is provided.
- patchA, patchB
Patch, default: None Optional Patches at posA and posB, respectively. If given, the arrow path is clipped by these patches such that head and tail are at the border of the patches.
Ignored if path is provided.
- shrinkA, shrinkBfloat, default: 2
Shorten the arrow path at posA and posB by this amount in points. This allows to add a margin between the intended start/end points and the arrow.
Ignored if path is provided.
- mutation_scalefloat, default: 1
Value with which attributes of arrowstyle (e.g., head_length) will be scaled.
- mutation_aspectNone or float, default: None
The height of the rectangle will be squeezed by this value before the mutation and the mutated box will be stretched by the inverse of it.
- Other Parameters:
- **kwargs
Patchproperties, optional Here is a list of available
Patchproperties:Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
unknown
bool
antialiasedoraabool or None
CapStyleor {'butt', 'projecting', 'round'}BboxBaseor Nonebool
Patch or (Path, Transform) or None
color or None
color or None
bool
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
color or 'edge' or None
bool
JoinStyleor {'miter', 'round', 'bevel'}object
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
float or None
bool
list of
AbstractPathEffectNone or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
In contrast to other patches, the default
capstyleandjoinstyleforFancyArrowPatchare set to"round".
- **kwargs
- draw(renderer)[source]#
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visiblereturns False).- Parameters:
- renderer
RendererBasesubclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- get_connectionstyle()[source]#
Return the
ConnectionStyleused.
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, hatchcolor=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]#
Set multiple properties at once.
Supported properties are
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
antialiasedoraabool or None
[ '-' | '<-' | '->' | '<->' | '<|-' | '-|>' | '<|-|>' | ']-' | '-[' | ']-[' | '|-|' | ']->' | '<-[' | 'simple' | 'fancy' | 'wedge' ]
CapStyleor {'butt', 'projecting', 'round'}BboxBaseor Nonebool
Patch or (Path, Transform) or None
[ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ]
color or None
color or None
bool
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
color or 'edge' or None
bool
JoinStyleor {'miter', 'round', 'bevel'}object
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
float or None
bool
float
float
list of
AbstractPathEffectNone or bool or float or callable
unknown
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
- set_arrowstyle(arrowstyle=None, **kwargs)[source]#
Set the arrow style, possibly with further attributes.
Attributes from the previous arrow style are not reused.
Without argument (or with
arrowstyle=None), the available box styles are returned as a human-readable string.- Parameters:
- arrowstylestr or
ArrowStyle The style of the arrow: either a
ArrowStyleinstance, or a string, which is the style name and optionally comma separated attributes (e.g. "Fancy,head_length=0.2"). Such a string is used to construct aArrowStyleobject, as documented in that class.The following arrow styles are available:
Class
Name
Parameters
Curve
-None
CurveA
<-head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveB
->head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveAB
<->head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledA
<|-head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledB
-|>head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
CurveFilledAB
<|-|>head_length=0.4, head_width=0.2, widthA=1.0, widthB=1.0, lengthA=0.2, lengthB=0.2, angleA=0, angleB=0, scaleA=None, scaleB=None
BracketA
]-widthA=1.0, lengthA=0.2, angleA=0
BracketB
-[widthB=1.0, lengthB=0.2, angleB=0
BracketAB
]-[widthA=1.0, lengthA=0.2, angleA=0, widthB=1.0, lengthB=0.2, angleB=0
BarAB
|-|widthA=1.0, angleA=0, widthB=1.0, angleB=0
BracketCurve
]->widthA=1.0, lengthA=0.2, angleA=None
CurveBracket
<-[widthB=1.0, lengthB=0.2, angleB=None
Simple
simplehead_length=0.5, head_width=0.5, tail_width=0.2
Fancy
fancyhead_length=0.4, head_width=0.4, tail_width=0.4
Wedge
wedgetail_width=0.3, shrink_factor=0.5
- **kwargs
Additional attributes for the arrow style. See the table above for supported parameters.
- arrowstylestr or
Examples
set_arrowstyle("Fancy,head_length=0.2") set_arrowstyle("fancy", head_length=0.2)
- set_connectionstyle(connectionstyle=None, **kwargs)[source]#
Set the connection style, possibly with further attributes.
Attributes from the previous connection style are not reused.
Without argument (or with
connectionstyle=None), the available box styles are returned as a human-readable string.- Parameters:
- connectionstylestr or
ConnectionStyle The style of the connection: either a
ConnectionStyleinstance, or a string, which is the style name and optionally comma separated attributes (e.g. "Arc,armA=30,rad=10"). Such a string is used to construct aConnectionStyleobject, as documented in that class.The following connection styles are available:
Class
Name
Parameters
Arc3
arc3rad=0.0
Angle3
angle3angleA=90, angleB=0
Angle
angleangleA=90, angleB=0, rad=0.0
Arc
arcangleA=0, angleB=0, armA=None, armB=None, rad=0.0
Bar
bararmA=0.0, armB=0.0, fraction=0.3, angle=None
- **kwargs
Additional attributes for the connection style. See the table above for supported parameters.
- connectionstylestr or
Examples
set_connectionstyle("Arc,armA=30,rad=10") set_connectionstyle("arc", armA=30, rad=10)
- set_mutation_aspect(aspect)[source]#
Set the aspect ratio of the bbox mutation.
- Parameters:
- aspectfloat
- set_patchA(patchA)[source]#
Set the tail patch.
- Parameters:
- patchA
patches.Patch
- patchA
- set_patchB(patchB)[source]#
Set the head patch.
- Parameters:
- patchB
patches.Patch
- patchB