matplotlib.pyplot.spy#
- matplotlib.pyplot.spy(Z, *, precision=0, marker=None, markersize=None, aspect='equal', origin='upper', **kwargs)[source]#
绘制 2D 数组的稀疏模式。
可视化数组的非零值。
提供两种绘图样式:图像(image)和标记(marker)。两者均可用于完整数组,但仅标记样式适用于
scipy.sparse.spmatrix实例。图像样式
如果 marker 和 markersize 为 None,则使用
imshow。任何额外剩余的关键字参数都将传递给此方法。标记样式
如果 Z 是
scipy.sparse.spmatrix,或者 marker 或 markersize 不为 None,则会返回一个Line2D对象,其中 marker 的值决定了标记类型,任何剩余的关键字参数将传递给plot。- 参数:
- Z(M, N) 数组类型
要绘制的数组。
- precisionfloat 或 'present',默认值:0
如果 precision 为 0,则绘制所有非零值。否则,将绘制满足 \(|Z| > precision\) 的值。
对于
scipy.sparse.spmatrix实例,还可以传递 'present'。在这种情况下,数组中存在的任何值都将被绘制,即使其值严格为零。- aspect{'equal', 'auto', None} 或 float,默认值:'equal'
Axes 的纵横比。此参数对于图像尤为重要,因为它决定了数据像素是否为正方形。
此参数是显式调用
Axes.set_aspect的快捷方式。详情请参考该函数。'equal':确保纵横比为 1。像素将为正方形。
'auto':Axes 保持固定,纵横比会调整,以便数据适合 Axes。通常,这将导致非正方形像素。
None:使用
rcParams["image.aspect"](默认值:'equal')。
- origin{'upper', 'lower'},默认:
rcParams["image.origin"](默认值:'upper') 将数组的 [0, 0] 索引放在 Axes 的左上角或左下角。'upper' 约定通常用于矩阵和图像。
- 返回:
- 其他参数:
- **kwargs
支持的附加参数取决于绘图样式。
对于图像样式,可以传递
imshow的以下附加参数:对于标记样式,可以传递除 linestyle 之外的任何
Line2D属性属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值
BboxBase或 None布尔值
Patch 或 (Path, Transform) 或 None
CapStyle或 {'butt', 'projecting', 'round'}JoinStyle或 {'miter', 'round', 'bevel'}浮点数序列(点中的开/关墨迹)或 (None, None)
(2, N) 数组或两个一维数组
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'},默认值: 'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
颜色 或 None
str
布尔值
object
{'-', '--', '-.', ':', '', ...} 或 (offset, on-off-seq)
浮点数
标记样式字符串、
Path或MarkerStyle浮点数
markersize或ms浮点数
None 或 int 或 (int, int) 或 slice 或 list[int] 或 float 或 (float, float) 或 list[bool]
布尔值
浮点数或 callable[[Artist, Event], tuple[bool, dict]]
浮点数
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
CapStyle或 {'butt', 'projecting', 'round'}JoinStyle或 {'miter', 'round', 'bevel'}未知
str
布尔值
一维数组
一维数组
浮点数
备注
注意
这是 pyplot 包装器,对应于
axes.Axes.spy。