Module plottools.arrows
Drawing arrows.
Axes member functions
harrow()
: draw a horizontal arrow with annotation on the arrow.varrow()
: draw a vertical arrow with annotation on the arrow.point_to()
: text with arrow pointing to a point.
Settings
arrow_style()
: generate an arrow style.generic_arrow_styles()
: some generic arrow styles.
Display
plot_arrow_styles()
: plot names and arrows of all available arrow styles.
Install/uninstall arrows functions
You usually do not need to call these functions. Upon loading the arrows
module, install_arrows()
is called automatically.
install_arrows()
: install functions of the arrows module in matplotlib.uninstall_arrows()
: uninstall all code of the arrows module from matplotlib.
Functions
def harrow(ax, x, y, dx, heads='right', text=None, va='bottom', dist=3.0, style='>', shrink=0, lw=1, color='k', head_width=15, head_length=15, transform=None, **kwargs)
-
Draw a horizontal arrow with annotation on the arrow.
Parameters
ax
:matplotlib axes
- Axes on which to draw the arrow.
x
:float
- X-coordinate of starting point of arrow in data coordinates.
y
:float
- Y-coordinate of starting point of arrow in data coordinates.
dx
:float
- Length of arrow in data x-coordinates.
heads
:string
- One of 'left', '<', 'right', '>', 'both', '<>', 'none', or '', Specifies whether to draw the arrow head at the starting point ('left', '<'), at the end ('right', '>'), on both ends ('both', '<>'), or none ('none', '').
text
:string
- Text for annotating the arrow. A formatting instruction within text (e.g. 'd=%.1fm')
is replaced by
dx
. va
:string
- Place text annotation above ('top') or below ('bottom') the arrow.
dist
:float
- Distance of text annotation from arrow in points.
style
:string
- Appearance of the arrow head: '>': line arrow, '|>': filled arrow, '>>': fancy arrow, '|': bar
shrink
:float
- Shrink arrow away from endpoints.
lw
:float
- Linewidth of line in points.
color
:matplotlib color
- Color of line and arrow.
head_width
:float
- Width of arrow head in points.
head_length
:float
- Length of arrow head in points.
transform
:matplotlib.Transform
- Defines coordinate system for
x
,y
, anddx
. Defaults to data coordinates. **kwargs
:key-word arguments
- Formatting of the annotation text, passed on to text().
A
zorder
argument is also applied to the arrow.
See Also
def varrow(ax, x, y, dy, heads='right', text=None, ha='right', dist=3.0, style='>', shrink=0, lw=1, color='k', head_width=15, head_length=15, transform=None, **kwargs)
-
Draw a vertical arrow with annotation on the arrow.
Parameters
ax
:matplotlib axes
- Axes on which to draw the arrow.
x
:float
- X-coordinate of starting point of arrow in data coordinates.
y
:float
- Y-coordinate of starting point of arrow in data coordinates.
dx
:float
- Length of arrow in data x-coordinates.
heads
:string
- One of 'left', '<', 'right', '>', 'both', '<>', 'none', or '', Specifies whether to draw the arrow head at the starting point ('left', '<'), at the end ('right', '>'), on both ends ('both', '<>'), or none ('none', '').
text
:string
- Text for annotating the arrow. A formatting instruction within text (e.g. 'd=%.1fm')
is replaced by
dy
. ha
:string
- Place text annotation to the left ('left') or right ('right') of the arrow.
dist
:float
- Distance of text annotation from arrow in points.
style
:string
- Appearance of the arrow head: '>': line arrow, '|>': filled arrow, '>>': fancy arrow, '|': bar
shrink
:float
- Shrink arrow away from endpoints.
lw
:float
- Linewidth of line in points.
color
:matplotlib color
- Color of line and arrow.
head_width
:float
- Width of arrow head in points.
head_length
:float
- Length of arrow head in points.
transform
:matplotlib.Transform
- Defines coordinate system for
x
,y
, anddx
. Defaults to data coordinates. **kwargs
:key-word arguments
- Formatting of the annotation text, passed on to text().
A
zorder
argument is also applied to the arrow.
See Also
def point_to(ax, text, xyfrom, xyto, radius=0.2, relpos=(1, 0.5), heads='right', style='>', shrink=0, lw=1, color='k', head_width=15, head_length=15, **kwargs)
-
Text with arrow pointing to a point.
Parameters
ax
:matplotlib axes
- Axes on which to draw the text and arrow.
text
:string
- Text placed at
xyfrom
. xyfrom
:tuple
offloats
- X- and y-coordinates of text position in data coordinates.
xyto
:tuple
offloats
- X- and y-coordinates of arrow point in data coordinates.
radius
:float
- Radius of arrow line. Negative curves to the right. Relative to arrow length.
relpos
:tuple
offloats
- X- and y-coordinate of starting point of arrow on text box. Between 0 and 1.
heads
:string
- One of 'left', '<', 'right', '>', 'both', '<>', 'none', or '', Specifies whether to draw the arrow head at the starting point ('left', '<'), at the end ('right', '>'), on both ends ('both', '<>'), or none ('none', '').
style
:string
- Appearance of the arrow head: '>': line arrow, '|>': filled arrow, '>>': fancy arrow
shrink
:float
- Shrink arrow away from endpoints.
lw
:float
- Linewidth of line in points.
color
:matplotlib color
- Color of line and arrow.
head_width
:float
- Width of arrow head in points.
head_length
:float
- Length of arrow head in points.
**kwargs
:key-word arguments
- Formatting of the text, passed on to annotate().
See Also
def arrow_style(namespace, name, dist=3.0, style='>', shrink=0, lw=1, color='k', head_width=15, head_length=15, **kwargs)
-
Generate an arrow style.
Add dictionary with name 'as'+name to
namespace
and toars
Parameters
namespace
:class
orNone
- Namespace to which the generated arrow style is added. If None add arrow style to the main module.
name
:string
- The name of the arrow style, the prefix 'as' is prepended.
dist
:float
- Distance of text annotation from arrow in points (for harrow() and varrow()).
style
:string
- Appearance of the arrow head: '>': line arrow, '|>': filled arrow, '>>': fancy arrow, '|': bar
shrink
:float
- Shrink arrow away from endpoints.
lw
:float
- Linewidth of line in points.
color
:matplotlib color
- Color of line and arrow.
head_width
:float
- Width of arrow head in points.
head_length
:float
- Length of arrow head in points.
**kwargs
:key-word arguments
- Formatting of the annotation text, passed on to text().
See Also
harrow()
,varrow()
,point_to()
,plot_arrow_styles()
,generic_arrow_styles()
def generic_arrow_styles(namespace, palette, scale=1)
-
Some generic arrow styles.
asLine
: simple arrowasFilled
: arrow with filled headasPoint
: big arrow with filled head and thick lineasPointSmall
: arrow with filled head and thin lineasMarker
: arrow with filled head, annotation on a transparent background
This is just a suggestion. Copy it and adapt it to your needs!
Parameters
namespace
:class
orNone
- Namespace to which the generated arrow style is added. If None add arrow style to the main module.
palette
:dict
- Color palette. Uses black for the arrow and white for text background.
scale
:float
- Scale factor for line width, head height and width.
See Also
def plot_arrow_styles(ax, namespace=None)
-
Plot names and arrows of all available arrow styles.
Parameters
ax
:matplotlib axes
- Subplot to use for plotting the arrow styles.
namespace
:class
orNone
- Namespace on which styles are defined. If None take styles from the main module.
See Also
def install_arrows()
def uninstall_arrows()
def demo()
-
Run a demonstration of the arrows module.