matplotlib.pyplot.axhline#
- matplotlib.pyplot.axhline(y=0, xmin=0, xmax=1, **kwargs)[源代码][源代码]#
添加一条横跨整个或部分 Axes 的水平线。
注意:如果你想在数据坐标中设置x轴的限制,请使用
hlines
代替。- 参数:
- 返回:
- 其他参数:
- **kwargs
有效的关键字参数是
Line2D
属性,除了 'transform' 之外:属性
描述
一个过滤函数,它接收一个 (m, n, 3) 的浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和从图像左下角开始的两个偏移量
标量或无
布尔
抗锯齿
或 aa布尔
BboxBase
或 None布尔
补丁或(路径,变换)或无
颜色
或 cCapStyle
或 {'butt', 'projecting', 'round'}JoinStyle
或 {'miter', 'round', 'bevel'}浮点数序列(开/关墨水以点为单位)或 (None, None)
(2, N) 数组或两个一维数组
drawstyle
或 ds{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, 默认值: 'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
color or None
str
布尔
对象
linestyle
或 ls{'-', '--', '-.', ':', '', (偏移, 开-关-序列), ...}
linewidth
或 lw浮动
标记样式字符串,
Path
或MarkerStyle
markeredgecolor
或 mecmarkeredgewidth
或 mew浮动
markerfacecolor
或 mfcmarkerfacecoloralt
或 mfcaltmarkersize
或 ms浮动
None 或 int 或 (int, int) 或 slice 或 list[int] 或 float 或 (float, float) 或 list[bool]
布尔
float 或 callable[[Artist, Event], tuple[bool, dict]]
浮动
布尔
(scale: float, length: float, randomness: float)
布尔值或无
CapStyle
或 {'butt', 'projecting', 'round'}JoinStyle
或 {'miter', 'round', 'bevel'}未知
str
布尔
一维数组
一维数组
浮动
注释
备注
这是
axes.Axes.axhline
的 pyplot 包装器。示例
在 'y' = 0 处绘制一条横跨 x 范围的粗红色水平线:
>>> axhline(linewidth=4, color='r')
在 'y' = 1 处绘制一条默认的水平线,跨越 x 范围:
>>> axhline(y=1)
在 'y' = .5 处绘制一条默认的水平线,该线跨越 x 范围的中间一半:
>>> axhline(y=.5, xmin=0.25, xmax=0.75)