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

Display

Install/uninstall arrows functions

You usually do not need to call these functions. Upon loading the arrows module, install_arrows() is called automatically.

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, and dx. 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

varrow(), point_to(), arrow_style()

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, and dx. 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

harrow(), point_to(), arrow_style()

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 of floats
X- and y-coordinates of text position in data coordinates.
xyto : tuple of floats
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 of floats
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

harrow(), varrow(), arrow_style()

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 to ars

Parameters

namespace : class or None
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 arrow
  • asFilled: arrow with filled head
  • asPoint: big arrow with filled head and thick line
  • asPointSmall: arrow with filled head and thin line
  • asMarker: 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 or None
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

arrow_style(), plot_arrow_styles()

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 or None
Namespace on which styles are defined. If None take styles from the main module.

See Also

arrow_style(), generic_arrow_styles()

def install_arrows()

Install functions of the arrows module in matplotlib.

See Also

uninstall_arrows()

def uninstall_arrows()

Uninstall all code of the arrows module from matplotlib.

See Also

install_arrows()

def demo()

Run a demonstration of the arrows module.