matplotlib.patches.ArrowStyle#

classmatplotlib.patches.ArrowStyle(stylename,**kwargs)[source]#

Bases:_Style

ArrowStyle is a container class which defines severalarrowstyle classes, which is used to create an arrow path along agiven path. These are mainly used withFancyArrowPatch.

An arrowstyle object can be either created as:

ArrowStyle.Fancy(head_length=.4,head_width=.4,tail_width=.4)

or:

ArrowStyle("Fancy",head_length=.4,head_width=.4,tail_width=.4)

or:

ArrowStyle("Fancy, head_length=.4, head_width=.4, tail_width=.4")

The following classes are defined

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

simple

head_length=0.5, head_width=0.5, tail_width=0.2

Fancy

fancy

head_length=0.4, head_width=0.4, tail_width=0.4

Wedge

wedge

tail_width=0.3, shrink_factor=0.5

For an overview of the visual appearance, seeAnnotation arrow style reference.

An instance of any arrow style class is a callable object,whose call signature is:

__call__(self,path,mutation_size,linewidth,aspect_ratio=1.)

and it returns a tuple of aPath instance and a booleanvalue.path is aPath instance along which the arrowwill be drawn.mutation_size andaspect_ratio have the samemeaning as inBoxStyle.linewidth is a line width to bestroked. This is meant to be used to correct the location of thehead so that it does not overshoot the destination point, but not allclasses support it.

Notes

angleA andangleB specify the orientation of the bracket, as either aclockwise or counterclockwise angle depending on the arrow type. 0 degreesmeans perpendicular to the line connecting the arrow's head and tail.

(Sourcecode,2x.png,png)

Return the instance of the subclass with the given style name.

classBarAB(widthA=1.0,angleA=0,widthB=1.0,angleB=0)[source]#

Bases:_Curve

An arrow with vertical bars| at both ends.

Parameters:
widthA, widthBfloat, default: 1.0

Width of the bracket.

angleA, angleBfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow='|-|'#
classBracketA(widthA=1.0,lengthA=0.2,angleA=0)[source]#

Bases:_Curve

An arrow with an outward square bracket at its start.

Parameters:
widthAfloat, default: 1.0

Width of the bracket.

lengthAfloat, default: 0.2

Length of the bracket.

angleAfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow=']-'#
classBracketAB(widthA=1.0,lengthA=0.2,angleA=0,widthB=1.0,lengthB=0.2,angleB=0)[source]#

Bases:_Curve

An arrow with outward square brackets at both ends.

Parameters:
widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow=']-['#
classBracketB(widthB=1.0,lengthB=0.2,angleB=0)[source]#

Bases:_Curve

An arrow with an outward square bracket at its end.

Parameters:
widthBfloat, default: 1.0

Width of the bracket.

lengthBfloat, default: 0.2

Length of the bracket.

angleBfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow='-['#
classBracketCurve(widthA=1.0,lengthA=0.2,angleA=None)[source]#

Bases:_Curve

An arrow with an outward square bracket at its start and a head atthe end.

Parameters:
widthAfloat, default: 1.0

Width of the bracket.

lengthAfloat, default: 0.2

Length of the bracket.

angleAfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow=']->'#
classCurve[source]#

Bases:_Curve

A simple curve without any arrow head.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

classCurveA(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)[source]#

Bases:_Curve

An arrow with a head at its start point.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='<-'#
classCurveAB(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)[source]#

Bases:_Curve

An arrow with heads both at the start and the end point.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='<->'#
classCurveB(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)[source]#

Bases:_Curve

An arrow with a head at its end point.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='->'#
classCurveBracket(widthB=1.0,lengthB=0.2,angleB=None)[source]#

Bases:_Curve

An arrow with an outward square bracket at its end and a head atthe start.

Parameters:
widthBfloat, default: 1.0

Width of the bracket.

lengthBfloat, default: 0.2

Length of the bracket.

angleBfloat, default: 0 degrees

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

arrow='<-['#
classCurveFilledA(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)[source]#

Bases:_Curve

An arrow with filled triangle head at the start.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='<|-'#
classCurveFilledAB(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)[source]#

Bases:_Curve

An arrow with filled triangle heads at both ends.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='<|-|>'#
classCurveFilledB(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)[source]#

Bases:_Curve

An arrow with filled triangle head at the end.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head, relative tomutation_size.

head_widthfloat, default: 0.2

Width of the arrow head, relative tomutation_size.

widthA, widthBfloat, default: 1.0

Width of the bracket.

lengthA, lengthBfloat, default: 0.2

Length of the bracket.

angleA, angleBfloat, default: 0

Orientation of the bracket, as a counterclockwise angle.0 degrees means perpendicular to the line.

scaleA, scaleBfloat, default:mutation_size

The scale of the brackets.

arrow='-|>'#
classFancy(head_length=0.4,head_width=0.4,tail_width=0.4)[source]#

Bases:_Base

A fancy arrow. Only works with a quadratic Bézier curve.

Parameters:
head_lengthfloat, default: 0.4

Length of the arrow head.

head_widthfloat, default: 0.4

Width of the arrow head.

tail_widthfloat, default: 0.4

Width of the arrow tail.

transmute(path,mutation_size,linewidth)[source]#

The transmute method is the very core of the ArrowStyle class andmust be overridden in the subclasses. It receives thepathobject along which the arrow will be drawn, and themutation_size, with which the arrow head etc. will be scaled.Thelinewidth may be used to adjust the path so that it does notpass beyond the given points. It returns a tuple of aPathinstance and a boolean. The boolean value indicate whether thepath can be filled or not. The return value can also be a list ofpaths and list of booleans of the same length.

classSimple(head_length=0.5,head_width=0.5,tail_width=0.2)[source]#

Bases:_Base

A simple arrow. Only works with a quadratic Bézier curve.

Parameters:
head_lengthfloat, default: 0.5

Length of the arrow head.

head_widthfloat, default: 0.5

Width of the arrow head.

tail_widthfloat, default: 0.2

Width of the arrow tail.

transmute(path,mutation_size,linewidth)[source]#

The transmute method is the very core of the ArrowStyle class andmust be overridden in the subclasses. It receives thepathobject along which the arrow will be drawn, and themutation_size, with which the arrow head etc. will be scaled.Thelinewidth may be used to adjust the path so that it does notpass beyond the given points. It returns a tuple of aPathinstance and a boolean. The boolean value indicate whether thepath can be filled or not. The return value can also be a list ofpaths and list of booleans of the same length.

classWedge(tail_width=0.3,shrink_factor=0.5)[source]#

Bases:_Base

Wedge(?) shape. Only works with a quadratic Bézier curve. Thestart point has a width of thetail_width and the end point has awidth of 0. At the middle, the width isshrink_factor*x*tail_width.

Parameters:
tail_widthfloat, default: 0.3

Width of the tail.

shrink_factorfloat, default: 0.5

Fraction of the arrow width at the middle point.

transmute(path,mutation_size,linewidth)[source]#

The transmute method is the very core of the ArrowStyle class andmust be overridden in the subclasses. It receives thepathobject along which the arrow will be drawn, and themutation_size, with which the arrow head etc. will be scaled.Thelinewidth may be used to adjust the path so that it does notpass beyond the given points. It returns a tuple of aPathinstance and a boolean. The boolean value indicate whether thepath can be filled or not. The return value can also be a list ofpaths and list of booleans of the same length.

Examples usingmatplotlib.patches.ArrowStyle#

Angle annotations on bracket arrows

Angle annotations on bracket arrows

Annotation arrow style reference

Annotation arrow style reference