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]#
-
绘制两个垂直箭头以指示方向。
- 参数:
- transform
Transform
所用坐标系的变换对象,例如
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* 的坐标给出。
- fontproperties
FontProperties
,可选 标签文本的字体属性。
- back_length浮点数,默认值:0.15
箭头交叉点后面箭头的分数。
- head_width浮点数,默认值:10
箭头头部的宽度,传递给
ArrowStyle
。- head_length浮点数,默认值:15
箭头头部的长度,传递给
ArrowStyle
。- tail_width浮点数,默认值:2
箭头尾部的宽度,传递给
ArrowStyle
。- text_props, arrow_props字典
文本和箭头的属性,传递给
TextPath
和FancyArrowPatch
。- **kwargs
转发给
AnchoredOffsetbox
的关键字参数。
- transform
- 属性:
- arrow_x, arrow_y
FancyArrowPatch
x 和 y 箭头
- text_path_x, text_path_y
TextPath
箭头标签的路径
- p_x, p_y
PathPatch
箭头标签的补丁
- box
AuxTransformBox
箭头和标签的容器。
- arrow_x, arrow_y
备注
如果 *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]#
一次性设置多个属性。
支持的属性包括:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
未知
未知
BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
字符串
浮点数
布尔值
对象
布尔值
(float, float) 或 callable
列表,包含
AbstractPathEffect
None 或 布尔值 或 浮点数 或 可调用对象
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
字符串
布尔值
浮点数
浮点数