mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar#
- class mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar(transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', label_top=False, fontproperties=None, fill_bar=None, **kwargs)[源代码][源代码]#
-
绘制一个带有居中标签的水平比例尺。
- 参数:
- 变换 :
Transform转换 当前使用的坐标系的变换对象,即
matplotlib.axes.Axes.transData。- 大小浮动
尺寸条的水平长度,以 transform 的坐标给出。
- 标签str
要显示的标签。
- locstr
尺寸条的位置。有效位置为 '左上'、'中上'、'右上'、'左中'、'中心'、'右中'、'左下'、'中下'、'右下'。为了向后兼容,也接受数值。详情请参见
Legend的参数 loc。- 填充float, 默认值: 0.1
标签和尺寸条周围的填充,以字体大小的分数表示。
- borderpadfloat, 默认值: 0.1
边框填充,以字体大小的分数表示。
- sepfloat, 默认值: 2
标签和尺寸条之间的间隔,以点为单位。
- frameonbool, 默认值: True
如果为真,则在水平条和标签周围绘制一个框。
- size_verticalfloat, 默认值: 0
尺寸条的垂直长度,以 transform 的坐标表示。
- 颜色str, 默认值: 'black'
尺寸条和标签的颜色。
- label_topbool, 默认值: False
如果为真,标签将位于尺寸条上方。
- fontproperties :
FontProperties, 可选FontProperties,可选 标签文本的字体属性。
- fill_barbool, 可选
如果为 True 且 size_vertical 非零,尺寸条将以指定颜色填充。如果 size_vertical 大于零,默认为 True,否则为 False。
- **kwargs
转发到
AnchoredOffsetbox的关键字参数。
- 变换 :
- 属性:
- size_bar
AuxTransformBox 尺寸条的容器。
- txt_label文本区域
用于尺寸条标签的容器。
- size_bar
注释
如果 prop 作为关键字参数传递,但 fontproperties 没有传递,那么 prop 将被认为是预期的 fontproperties。不支持同时使用 prop 和 fontproperties。
示例
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from mpl_toolkits.axes_grid1.anchored_artists import ( ... AnchoredSizeBar) >>> fig, ax = plt.subplots() >>> ax.imshow(np.random.random((10, 10))) >>> bar = AnchoredSizeBar(ax.transData, 3, '3 data units', 4) >>> ax.add_artist(bar) >>> fig.show()
使用所有可选参数
>>> import matplotlib.font_manager as fm >>> fontprops = fm.FontProperties(size=14, family='monospace') >>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5, ... sep=5, borderpad=0.5, frameon=False, ... size_vertical=0.5, color='white', ... 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>)[源代码]#
一次性设置多个属性。
支持的属性有
属性
描述
一个过滤函数,它接收一个 (m, n, 3) 的浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量
标量或无
布尔
未知
未知
BboxBase或 None布尔
补丁或(路径,变换)或无
str
浮动
布尔
对象
布尔
(浮点数, 浮点数) 或 可调用对象
None 或 bool 或 float 或 callable
布尔
(scale: float, length: float, randomness: float)
布尔值或无
str
布尔
浮动
浮动