matplotlib.pyplot.axvline#

matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, **kwargs)[源代码][源代码]#

添加一条贯穿整个或部分 Axes 的垂直线。

注意:如果你想在数据坐标中设置y轴限制,请使用 vlines 代替。

参数:
xfloat, 默认值: 0

y 位置在 数据坐标 中。

yminfloat, 默认值: 0

坐标系 中的起始 y 位置。应在 0 和 1 之间,0 表示图的底部,1 表示图的顶部。

ymaxfloat, 默认值: 1

坐标系 中的结束 y 位置。应在 0 和 1 之间,0 表示图的底部,1 表示图的顶部。

返回:
Line2D
其他参数:
**kwargs

有效的关键字参数是 Line2D 属性,除了 'transform' 之外:

属性

描述

agg_filter

一个过滤函数,它接收一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量

alpha

标量或无

animated

布尔

抗锯齿 或 aa

布尔

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

补丁或(路径,变换)或无

颜色 或 c

color

dash_capstyle

CapStyle 或 {'butt', 'projecting', 'round'}

dash_joinstyle

JoinStyle 或 {'miter', 'round', 'bevel'}

虚线

浮点数序列(开/关墨水以点为单位)或 (None, None)

数据

(2, N) 数组或两个一维数组

drawstyle 或 ds

{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, 默认: 'default'

figure

FigureSubFigure

fillstyle

{'full', 'left', 'right', 'bottom', 'top', 'none'}

gapcolor

color or None

gid

str

in_layout

布尔

标签

对象

linestyle 或 ls

{'-', '--', '-.', ':', '', (偏移, 开关序列), ...}

linewidth 或 lw

浮动

标记

标记样式字符串,PathMarkerStyle

markeredgecolor 或 mec

color

markeredgewidth 或 mew

浮动

markerfacecolor 或 mfc

color

markerfacecoloralt 或 mfcalt

color

markersize 或 ms

浮动

markevery

None 或 int 或 (int, int) 或 slice 或 list[int] 或 float 或 (float, float) 或 list[bool]

鼠标悬停

布尔

path_effects

AbstractPathEffect 的列表

picker

float 或 callable[[Artist, Event], tuple[bool, dict]]

pickradius

浮动

光栅化

布尔

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

solid_capstyle

CapStyle 或 {'butt', 'projecting', 'round'}

solid_joinstyle

JoinStyle 或 {'miter', 'round', 'bevel'}

transform

未知

url

str

可见

布尔

xdata

1D 数组

ydata

1D 数组

zorder

浮动

参见

vlines

在数据坐标中添加垂直线。

axvspan

在轴上添加一个垂直跨度(矩形)。

axline

添加一条具有任意斜率的线。

注释

备注

这是 axes.Axes.axvlinepyplot 包装器

示例

  • 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)
    

使用 matplotlib.pyplot.axvline 的示例#

默认属性循环中的颜色

Colors in the default property cycle

无限行

Infinite lines