matplotlib.pyplot.axvline#
- matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, **kwargs)[source]#
添加一条垂直线,跨越整个或部分坐标轴。
注意:如果你想在数据坐标中设置y轴限制,请使用
vlines
代替。- 参数:
- 返回:
- 其他参数:
- **kwargs
有效的关键字参数是
Line2D
的属性,'transform' 除外属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
antialiased
oraa
布尔值
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), ...}
浮点数
marker style string,
Path
orMarkerStyle
浮点数
markersize
orms
浮点数
None 或 int 或 (int, int) 或 slice 或 list[int] 或 float 或 (float, float) 或 list[bool]
布尔值
list of
AbstractPathEffect
浮点数或 callable[[Artist, Event], tuple[bool, dict]]
浮点数
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
CapStyle
或 {'butt', 'projecting', 'round'}JoinStyle
或 {'miter', 'round', 'bevel'}未知
str
布尔值
一维数组
一维数组
浮点数
备注
注意
示例
在*x* = 0 处绘制一条粗红色的垂直线,该线跨越整个y范围
>>> axvline(linewidth=4, color='r')
在*x* = 1 处绘制一条默认垂直线,该线跨越整个y范围
>>> axvline(x=1)
在*x* = .5 处绘制一条默认垂直线,该线跨越y轴范围的中间一半
>>> axvline(x=.5, ymin=0.25, ymax=0.75)