matplotlib.lines.AxLine#

class matplotlib.lines.AxLine(xy1, xy2, slope, **kwargs)[source]#

基类:Line2D

一个帮助类,实现了 axline,通过在绘制时重新计算艺术家变换。

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

直线通过的第一个 (x, y) 坐标对。

xy2(浮点数, 浮点数) 或 None

直线通过的第二个 (x, y) 坐标对。xy2slope 都必须传递,但其中一个必须是 None。

slope浮点数 或 None

直线的斜率。xy2slope 都必须传递,但其中一个必须是 None。

draw(renderer)[source]#

使用给定的渲染器绘制 Artist(及其子对象)。

如果艺术家不可见(Artist.get_visible 返回 False),则此操作无效。

参数:
rendererRendererBase 子类。

备注

此方法在 Artist 子类中被覆盖。

get_slope()[source]#

返回直线的 slope 值。

get_transform()[source]#

返回此艺术家使用的 Transform 实例。

get_xy1()[source]#

返回直线的 xy1 值。

get_xy2()[source]#

返回直线的 xy2 值。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, dash_capstyle=<UNSET>, dash_joinstyle=<UNSET>, dashes=<UNSET>, data=<UNSET>, drawstyle=<UNSET>, fillstyle=<UNSET>, gapcolor=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, marker=<UNSET>, markeredgecolor=<UNSET>, markeredgewidth=<UNSET>, markerfacecolor=<UNSET>, markerfacecoloralt=<UNSET>, markersize=<UNSET>, markevery=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, slope=<UNSET>, snap=<UNSET>, solid_capstyle=<UNSET>, solid_joinstyle=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xdata=<UNSET>, xy1=<UNSET>, xy2=<UNSET>, ydata=<UNSET>, zorder=<UNSET>)[source]#

一次性设置多个属性。

支持的属性包括:

属性

描述

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

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

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: 浮点数)

slope

浮点数

snap

布尔值或 None

solid_capstyle

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

solid_joinstyle

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

transform

变换

url

str

visible

布尔值

xdata

一维数组

xy1

未知

xy2

未知

ydata

一维数组

zorder

浮点数

set_slope(slope)[source]#

设置直线的 *slope* 值。

注意

只有当直线是使用 *slope* 参数创建时,才能设置 *slope*。如果直线是使用 *xy2* 创建的,请使用 set_xy2

参数:
slope浮点数

直线的斜率。

set_xy1(*args, **kwargs)[source]#

设置直线的 *xy1* 值。

参数:
xy1元组[浮点数, 浮点数]

直线通过的点。

set_xy2(*args, **kwargs)[source]#

设置直线的 *xy2* 值。

注意

只有当直线是使用 *xy2* 参数创建时,才能设置 *xy2*。如果直线是使用 *slope* 创建的,请使用 set_slope

参数:
xy2元组[浮点数, 浮点数]

直线通过的点。