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='upper left', 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]#

基类: AnchoredOffsetbox

绘制两个垂直箭头以指示方向。

参数:
transformTransform

所用坐标系的变换对象,例如 matplotlib.axes.Axes.transAxes

label_x, label_y字符串

x 和 y 箭头的标签文本

length浮点数,默认值:0.15

箭头的长度,以 *transform* 的坐标给出。

fontsize浮点数,默认值:0.08

标签字符串的大小,以 *transform* 的坐标给出。

loc字符串,默认值:'upper left'

箭头的位置。有效位置包括 'upper left'、'upper center'、'upper right'、'center left'、'center'、'center right'、'lower left'、'lower center'、'lower right'。为了向后兼容,也接受数值。有关详细信息,请参阅 Legend 的 *loc* 参数。

anglefloat, 默认值: 0

箭头的角度,以度为单位。

aspect_ratio浮点数,默认值:1

arrow_x 和 arrow_y 长度的比例。负数可用于改变方向。

padfloat, 默认值:0.4

标签和箭头周围的填充,以字体大小的分数表示。

borderpad浮点数,默认值:0.4

边框填充,以字体大小的分数表示。

frameon布尔值,默认值:False

如果为 True,则在箭头和标签周围绘制一个框。

color字符串,默认值:'white'

箭头和标签的颜色。

alphafloat, 默认值: 1

箭头和标签的 Alpha 值

sep_x, sep_y浮点数,默认值:分别为 0.01 和 0

箭头和标签之间的间距,以 *transform* 的坐标给出。

fontpropertiesFontProperties,可选

标签文本的字体属性。

back_length浮点数,默认值:0.15

箭头交叉点后面箭头的分数。

head_width浮点数,默认值:10

箭头头部的宽度,传递给 ArrowStyle

head_length浮点数,默认值:15

箭头头部的长度,传递给 ArrowStyle

tail_width浮点数,默认值:2

箭头尾部的宽度,传递给 ArrowStyle

text_props, arrow_props字典

文本和箭头的属性,传递给 TextPathFancyArrowPatch

**kwargs

转发给 AnchoredOffsetbox 的关键字参数。

属性:
arrow_x, arrow_yFancyArrowPatch

x 和 y 箭头

text_path_x, text_path_yTextPath

箭头标签的路径

p_x, p_yPathPatch

箭头标签的补丁

boxAuxTransformBox

箭头和标签的容器。

备注

如果 *prop* 作为关键字参数传递,但 *fontproperties* 未传递,则 *prop* 被视为预期的 *fontproperties*。不支持同时使用 *prop* 和 *fontproperties*。

示例

>>> 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()

使用几个可选参数,创建指向下方的箭头和高对比度文本标签。

>>> 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)
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, bbox_to_anchor=<UNSET>, child=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, gid=<UNSET>, height=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, offset=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, zorder=<UNSET>)[source]#

一次性设置多个属性。

支持的属性包括:

属性

描述

agg_filter

一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量

alpha

浮点数或 None

animated

布尔值

bbox_to_anchor

未知

child

未知

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

figure

Figure

gid

字符串

height

浮点数

in_layout

布尔值

label

对象

mouseover

布尔值

offset

(float, float) 或 callable

path_effects

列表,包含 AbstractPathEffect

picker

None 或 布尔值 或 浮点数 或 可调用对象

rasterized

布尔值

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

transform

变换

url

字符串

visible

布尔值

width

浮点数

zorder

浮点数

使用 mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows 的示例#

定位方向箭头

定位方向箭头