You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows.html
Version 3.1.2
matplotlib
Fork me on GitHub

Table of Contents

mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows

class mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows(transform, label_x, label_y, length=0.15, fontsize=0.08, loc=2, angle=0, aspect_ratio=1, pad=0.4, borderpad=0.4, frameon=False, color='w', alpha=1, sep_x=0.01, sep_y=0, fontproperties=None, back_length=0.15, head_width=10, head_length=15, tail_width=2, text_props=None, arrow_props=None, **kwargs)[source]

Bases: matplotlib.offsetbox.AnchoredOffsetbox

Draw two perpendicular arrows to indicate directions.

Parameters:
transform : matplotlib.transforms.Transform

The transformation object for the coordinate system in use, i.e., matplotlib.axes.Axes.transAxes.

label_x, label_y : string

Label text for the x and y arrows

length : int or float, optional

Length of the arrow, given in coordinates of transform. Defaults to 0.15.

fontsize : int, optional

Size of label strings, given in coordinates of transform. Defaults to 0.08.

loc : int, optional

Location of the direction arrows. Valid location codes are:

'upper right'  : 1,
'upper left'   : 2,
'lower left'   : 3,
'lower right'  : 4,
'right'        : 5,
'center left'  : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center'       : 10

Defaults to 2.

angle : int or float, optional

The angle of the arrows in degrees. Defaults to 0.

aspect_ratio : int or float, optional

The ratio of the length of arrow_x and arrow_y. Negative numbers can be used to change the direction. Defaults to 1.

pad : int or float, optional

Padding around the labels and arrows, in fraction of the font size. Defaults to 0.4.

borderpad : int or float, optional

Border padding, in fraction of the font size. Defaults to 0.4.

frameon : bool, optional

If True, draw a box around the arrows and labels. Defaults to False.

color : str, optional

Color for the arrows and labels. Defaults to white.

alpha : int or float, optional

Alpha values of the arrows and labels Defaults to 1.

sep_x, sep_y : int or float, optional

Separation between the arrows and labels in coordinates of transform. Defaults to 0.01 and 0.

fontproperties : matplotlib.font_manager.FontProperties, optional

Font properties for the label text.

back_length : float, optional

Fraction of the arrow behind the arrow crossing. Defaults to 0.15.

head_width : int or float, optional

Width of arrow head, sent to ArrowStyle. Defaults to 10.

head_length : int or float, optional

Length of arrow head, sent to ArrowStyle. Defaults to 15.

tail_width : int or float, optional

Width of arrow tail, sent to ArrowStyle. Defaults to 2.

text_props, arrow_props : dict

Properties of the text and arrows, passed to matplotlib.text.TextPath and matplotlib.patches.FancyArrowPatch

**kwargs

Keyworded arguments to pass to matplotlib.offsetbox.AnchoredOffsetbox.

Notes

If prop is passed as a keyword argument, but fontproperties is not, then prop is be assumed to be the intended fontproperties. Using both prop and fontproperties is not supported.

Examples

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from mpl_toolkits.axes_grid1.anchored_artists import (
...     AnchoredDirectionArrows)
>>> fig, ax = plt.subplots()
>>> ax.imshow(np.random.random((10,10)))
>>> arrows = AnchoredDirectionArrows(ax.transAxes, '111', '110')
>>> ax.add_artist(arrows)
>>> fig.show()

Using several of the optional parameters, creating downward pointing arrow and high contrast text labels.

>>> import matplotlib.font_manager as fm
>>> fontprops = fm.FontProperties(family='monospace')
>>> arrows = AnchoredDirectionArrows(ax.transAxes, 'East', 'South',
...                                  loc='lower left', color='k',
...                                  aspect_ratio=-1, sep_x=0.02,
...                                  sep_y=-0.01,
...                                  text_props={'ec':'w', 'fc':'k'},
...                                  fontproperties=fontprops)
Attributes:
arrow_x, arrow_y : matplotlib.patches.FancyArrowPatch

Arrow x and y

text_path_x, text_path_y : matplotlib.text.TextPath

Path for arrow labels

p_x, p_y : matplotlib.patches.PathPatch

Patch for arrow labels

box : matplotlib.offsetbox.AuxTransformBox

Container for the arrows and labels.

Examples using mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows