matplotlib.pyplot.broken_barh#

matplotlib.pyplot.broken_barh(xranges, yrange, align='bottom', *, data=None, **kwargs)[源码]#

绘制一系列水平矩形。

为 xranges 中的每个元素绘制一个矩形。所有矩形均具有由 yrange 定义的相同垂直位置和大小。

参数:
xranges元组序列 (xmin, xwidth)

矩形的 x 轴位置和跨度。对于每个元组 (xmin, xwidth),矩形的绘制范围从 xmin 到 xmin + xwidth。

yrange(ypos, yheight)

所有矩形的 y 轴位置和跨度。

align{"bottom", "center", "top"}, 默认值: 'bottom'

yrange 相对于 y 轴位置的对齐方式。可选值:

  • "bottom":结果 y 轴范围为 [ypos, ypos + yheight]

  • "center":结果 y 轴范围为 [ypos - yheight/2, ypos + yheight/2]

  • "top":结果 y 轴范围为 [ypos - yheight, ypos]

于版本 3.11 新增。

返回:
PolyCollection
其他参数:
data可索引对象,可选

如果提供,所有参数也接受字符串 s,如果 s 是 data 中的键,则将其解释为 data[s]。

**kwargsPolyCollection 属性

每个 kwarg 可以是应用于所有矩形的单个参数(例如 `facecolors='black'`),

facecolors='black'

也可以是循环使用的参数序列(例如 `facecolors=('black', 'blue')`),

facecolors=('black', 'blue')

这将创建交替的黑色和蓝色矩形。

支持的关键字

属性

描述

agg_filter

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

alpha

类数组或浮点数或 None

animated

布尔值

antialiased 或 aa 或 antialiaseds

布尔值或布尔值列表

array

类数组或 None

capstyle

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

clim

(vmin: 浮点数, vmax: 浮点数)

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

cmap

Colormap 或 字符串 或 None

color

颜色 或 RGBA 元组列表

edgecolor 或 ec 或 edgecolors

color 或 color 列表 或 'face'

facecolor 或 facecolors 或 fc

color 或 color 列表

figure

Figure 或 SubFigure

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

hatch_linewidth

未知

hatchcolor

color 或 color 列表 或 'edge'

in_layout

布尔值

joinstyle

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

label

object

linestyle 或 dashes 或 linestyles 或 ls

{'-', '--', '-.', ':', '', ...} 或 (offset, on-off-seq) 或其列表

linewidth 或 linewidths 或 lw

浮点数或浮点数列表

mouseover

布尔值

norm

Normalize 或 字符串 或 None

offset_transform 或 transOffset

变换

offsets

(N, 2) 或 (2,) 类数组

path_effects

AbstractPathEffect 列表

paths

类数组列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

pickradius

浮点数

rasterized

布尔值

sizes

numpy.ndarray 或 None

sketch_params

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

snap

布尔值或 None

transform

变换

url

str

字符串列表或 None

urls

verts

类数组列表

verts_and_codes

未知

visible

布尔值

zorder

浮点数

备注

注意

这是 pyplot 封装器,对应 axes.Axes.broken_barh。

使用 matplotlib.pyplot.broken_barh 的示例#

断裂水平条

断裂水平条