matplotlib.axes.Axes.axline#

Axes.axline(xy1, xy2=None, *, slope=None, **kwargs)[源]#

添加一条无限长的直线。

该线可以通过两个点 xy1xy2 定义,也可以通过一个点 xy1 和一个 斜率 定义。

这会在“屏幕上”绘制一条直线,而不考虑 x 和 y 刻度,因此也适用于在半对数图中绘制指数衰减、在对数图中绘制幂律等。然而,斜率 只能用于线性刻度;对于所有其他刻度,它没有明确的含义,因此行为是未定义的。对于非线性刻度,请使用点 xy1xy2 来指定直线。

transform 关键字参数仅适用于点 xy1xy2斜率(如果给定)始终以数据坐标表示。例如,这可以与 ax.transAxes 一起使用,以绘制具有固定斜率的网格线。

参数:
xy1, xy2(浮点数, 浮点数)

直线的经过点。必须提供 xy2slope 中的一个。

slope浮点数, 可选

直线的斜率。必须提供 xy2slope 中的一个。

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

有效的 kwargs 是 Line2D 属性

属性

描述

agg_filter

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

alpha

浮点数或 None

animated

布尔值

antialiasedaa

布尔值

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

colorc

color

dash_capstyle

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

dash_joinstyle

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

dashes

浮点数序列(点中的开/关墨迹)或 (None, None)

data

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

drawstyleds

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

figure

FigureSubFigure

fillstyle

{'完整', '左', '右', '底部', '顶部', '无'}

gapcolor

颜色 或 None

gid

str

in_layout

布尔值

label

object

linestylels

{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}

linewidthlw

浮点数

marker

标记样式字符串, PathMarkerStyle

markeredgecolormec

color

markeredgewidthmew

浮点数

markerfacecolormfc

color

markerfacecoloraltmfcalt

color

markersizems

浮点数

markevery

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

mouseover

布尔值

path_effects

AbstractPathEffect 组成的列表

picker

浮点数或 callable[[Artist, Event], tuple[bool, dict]]

pickradius

浮点数

rasterized

布尔值

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

solid_capstyle

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

solid_joinstyle

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

transform

未知

url

str

visible

布尔值

xdata

一维数组

ydata

一维数组

zorder

浮点数

另请参阅

axhline

用于水平线

axvline

用于垂直线

示例

绘制一条穿过 (0, 0) 和 (1, 1) 的粗红色直线

>>> axline((0, 0), (1, 1), linewidth=4, color='r')

使用 matplotlib.axes.Axes.axline 的示例#

无限线条

无限线条

安斯库姆四重奏

安斯库姆四重奏