Matplotlib函数速查
把每个来源技术条目对应到当前版本的真实接口。
学完这一章,你能够
- 把每个来源技术条目对应到当前版本的真实接口。
- 把每个来源技术条目对应到当前版本的真实接口。
显式对象与pyplot状态
Figure是整个图的容器,Axes是坐标系,Axis管理刻度与轴。不把Axes复数拼写误当多个坐标轴对象,也不把Figure保存与像素数组保存混淆。
本页保留pyplot、Axes、Figure、SubFigure的技术条目分组,但不宣称这些清单穷尽当前版本所有公开API。签名、可调用对象和属性分开,属性不能随意加括号调用。
版本差异必须显式处置
当前3.11已有grouped_bar与pie_label,不能凭旧经验判成不存在;当前pyplot没有supxlabel/supylabel,应调用Figure方法。mouseover与use_sticky_edges是属性,应读取/赋值而非当函数。
表中的候选接口必须在固定环境核对存在性和签名,读取签名不证明调用、参数组合或GUI行为全部验收。历史接口保留用途及迁移,不能因为名称不匹配就静默删除。
六组图形与布局实验
分别运行正余弦及峰值标注、2×2四种图、imshow与contourf、ggplot阻尼曲线300DPI输出、mosaic非均匀布局、twinx与inset放大。每个图明确数据与可观察对象,不能只提供一个综合图入口。
本站实际运行图:正余弦和离散采样峰值标注。

本站实际运行图:折线、散点、柱形和直方图。

本站实际运行图:同一二维函数的像素热图与等高线。

本站实际运行图:ggplot样式和阻尼曲线,另生成300DPI文件。

mosaic采用AA/BC等无歧义标签格,D若仅占一格不能说成纵跨两行。双y轴与通过可逆单位函数构造secondary轴是不同用途;本包分别演示并检查。
本站实际运行图:A跨上排、B/C/D各占下排一格。

本站实际运行图:独立双y轴、嵌入放大与可逆角度辅助轴。

诊断、配置与有效条件
Agg应保存文件而非期待show出现GUI。分类字符串按类别定位,数值/日期先转换成恰当类型;中文字体、布局、刻度过密与共享轴分别诊断。
pcolor/pcolormesh依据网格结构、遮罩与返回对象选择,不能把一个称更精确另一个称精度最低;pcolorfast采用的Artist随网格条件变化,不保证始终imshow。样式、rcParams与色图在作用域内使用,逐项索引仍保留待全文事实复核。
当前接口与配置分组 1
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| 使用方式 | 显式接口通过具体Figure/Axes调用;pyplot接口通过当前状态选择目标 | interface_comparison | 独立用途说明,不自动验收所有行为 |
| 适用场景 | 多图与可复用函数优先显式对象,快速探索也可使用pyplot | interface_comparison | 独立用途说明,不自动验收所有行为 |
| 代码示例 | fig, ax = plt.subplots(); ax.plot(x, y) 与 plt.plot(x, y)需明确当前坐标系 | interface_comparison | 独立用途说明,不自动验收所有行为 |
| 推荐程度 | 复杂图形采用显式对象更易追踪;不把两种接口视为不能混用 | interface_comparison | 独立用途说明,不自动验收所有行为 |
当前接口与配置分组 2
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| figure() | 所属Figure或SubFigure | pyplot.figure [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| subplots() | 创建画布及规则坐标系网格,返回形状受squeeze影响 | pyplot.subplots [method] (nrows: 'int' = 1, ncols: 'int' = 1, *, sharex: "bool | Literal['none', 'all', 'row', 'col']" = False, sharey: "bool | Literal['none', 'all', 'row', 'col']" = False, squeeze: 'bool' = True, width_ratios: 'Sequence[float] | None' = None, height_ratios: 'Sequence[float] | None' = None, subplot_kw: 'dict[str, Any] | None' = None, gridspec_kw: 'dict[str, Any] | None' = None, **fig_kw: 'Any') -> 'tuple[Figure, Any]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| subplot() | 按从1开始的行列位置选择或添加一个坐标系 | pyplot.subplot [method] (*args, **kwargs) -> 'Axes' | 存在性和签名记录,不代表所有参数组合实际运行 |
| subplot2grid() | 按网格起点及跨度建立坐标系 | pyplot.subplot2grid [method] (shape: 'tuple[int, int]', loc: 'tuple[int, int]', rowspan: 'int' = 1, colspan: 'int' = 1, fig: 'Figure | None' = None, **kwargs) -> 'matplotlib.axes.Axes' | 存在性和签名记录,不代表所有参数组合实际运行 |
| subplot_mosaic() | 按二维标签排列生成命名坐标系,重复标签须形成合法区域 | pyplot.subplot_mosaic [method] (mosaic: 'str | list[HashableList[_T]] | list[HashableList[Hashable]]', *, sharex: 'bool' = False, sharey: 'bool' = False, width_ratios: 'ArrayLike | None' = None, height_ratios: 'ArrayLike | None' = None, empty_sentinel: 'Any' = '.', subplot_kw: 'dict[str, Any] | None' = None, gridspec_kw: 'dict[str, Any] | None' = None, per_subplot_kw: 'dict[str | tuple[str, ...], dict[str, Any]] | dict[_T | tuple[_T, ...], dict[str, Any]] | dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None' = None, **fig_kw: 'Any') -> 'tuple[Figure, dict[str, matplotlib.axes.Axes]] | tuple[Figure, dict[_T, matplotlib.axes.Axes]] | tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axes() | 容器Axes列表 | pyplot.axes [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| gca() | 取得当前坐标系,必要时可能创建,不能当无副作用查询 | pyplot.gca [method] () -> 'Axes' | 存在性和签名记录,不代表所有参数组合实际运行 |
| gcf() | 取得当前画布,必要时可能创建 | pyplot.gcf [method] () -> 'Figure' | 存在性和签名记录,不代表所有参数组合实际运行 |
| sca() | 选择当前坐标系以供后续状态式调用 | pyplot.sca [method] (ax: 'Axes') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| cla() | 清除一个坐标系内容与相应设置,不关闭整个画布 | pyplot.cla [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| clf() | 清除当前画布中的坐标系和内容 | pyplot.clf [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| close() | 关闭pyplot管理的指定画布并释放其管理关系 | pyplot.close [method] (fig: "None | int | str | Figure | Literal['all']" = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| delaxes() | 从画布移除指定坐标系 | pyplot.delaxes [method] (ax: 'matplotlib.axes.Axes | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| fignum_exists() | 判断编号画布是否已登记 | pyplot.fignum_exists [method] (num: 'int | str') -> 'bool' | 存在性和签名记录,不代表所有参数组合实际运行 |
| get_figlabels() | 取得pyplot管理的画布标签 | pyplot.get_figlabels [method] () -> 'list[Any]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| get_fignums() | 取得pyplot管理的画布编号 | pyplot.get_fignums [method] () -> 'list[int]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| twinx() | 共享横轴并建立独立纵轴坐标系 | pyplot.twinx [method] (ax: 'matplotlib.axes.Axes | None' = None) -> '_AxesBase' | 存在性和签名记录,不代表所有参数组合实际运行 |
| twiny() | 共享纵轴并建立独立横轴坐标系 | pyplot.twiny [method] (ax: 'matplotlib.axes.Axes | None' = None) -> '_AxesBase' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 3
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| plot() | 按输入顺序绘制二维线及可选标记,返回Line2D集合 | pyplot.plot [method] (*args: 'float | ArrayLike | str', scalex: 'bool' = True, scaley: 'bool' = True, data: 'DataParamType' = None, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| scatter() | 以位置、面积及颜色映射创建PathCollection | pyplot.scatter [method] (x: 'float | ArrayLike', y: 'float | ArrayLike', s: 'float | ArrayLike | None' = None, c: 'ArrayLike | Sequence[ColorType] | ColorType | None' = None, *, marker: 'MarkerType | None' = None, cmap: 'str | Colormap | None' = None, norm: 'str | Normalize | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, alpha: 'float | None' = None, linewidths: 'float | Sequence[float] | None' = None, edgecolors: "Literal['face', 'none'] | ColorType | Sequence[ColorType] | None" = None, colorizer: 'Colorizer | None' = None, plotnonfinite: 'bool' = False, data: 'DataParamType' = None, **kwargs) -> 'PathCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| bar() | 绘制竖柱,bottom控制底座,width控制厚度 | pyplot.bar [method] (x: 'float | ArrayLike', height: 'float | ArrayLike', width: 'float | ArrayLike' = 0.8, bottom: 'float | ArrayLike | None' = None, *, align: "Literal['center', 'edge']" = 'center', data: 'DataParamType' = None, **kwargs) -> 'BarContainer' | 存在性和签名记录,不代表所有参数组合实际运行 |
| barh() | 绘制横条,left控制起点,height控制厚度 | pyplot.barh [method] (y: 'float | ArrayLike', width: 'float | ArrayLike', height: 'float | ArrayLike' = 0.8, left: 'float | ArrayLike | None' = None, *, align: "Literal['center', 'edge']" = 'center', data: 'DataParamType' = None, **kwargs) -> 'BarContainer' | 存在性和签名记录,不代表所有参数组合实际运行 |
| bar_label() | 在BarContainer条柱对应端点或中心放置文字 | pyplot.bar_label [method] (container: 'BarContainer', labels: 'ArrayLike | None' = None, *, fmt: 'str | Callable[[float], str]' = '%g', label_type: "Literal['center', 'edge']" = 'edge', padding: 'float | ArrayLike' = 0, **kwargs) -> 'list[Annotation]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| grouped_bar() | 按系列组织成分组柱图;属于当前3.11接口,旧环境需迁移 | pyplot.grouped_bar [method] (heights: 'Sequence[ArrayLike] | dict[str, ArrayLike] | np.ndarray | pd.DataFrame', *, positions: 'ArrayLike | None' = None, group_spacing: 'float | None' = 1.5, bar_spacing: 'float | None' = 0, tick_labels: 'Sequence[str] | None' = None, labels: 'Sequence[str] | None' = None, orientation: "Literal['vertical', 'horizontal']" = 'vertical', colors: 'Iterable[ColorType] | None' = None, **kwargs) -> 'list[BarContainer]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| pie() | 把非负组成数据映射为扇形,当前返回PieContainer | pyplot.pie [method] (x: 'ArrayLike', *, explode: 'ArrayLike | None' = None, labels: 'Sequence[str] | None' = None, colors: 'ColorType | Sequence[ColorType] | None' = None, autopct: 'str | Callable[[float], str] | None' = None, pctdistance: 'float' = 0.6, shadow: 'bool' = False, labeldistance: 'float | None' = 1.1, startangle: 'float' = 0, radius: 'float' = 1, counterclock: 'bool' = True, wedgeprops: 'dict[str, Any] | None' = None, textprops: 'dict[str, Any] | None' = None, center: 'tuple[float, float]' = (0, 0), frame: 'bool' = False, rotatelabels: 'bool' = False, normalize: 'bool' = True, hatch: 'str | Sequence[str] | None' = None, data: 'DataParamType' = None) -> 'PieContainer' | 存在性和签名记录,不代表所有参数组合实际运行 |
| pie_label() | 为饼图容器添加标签;需匹配当前版本接口 | pyplot.pie_label [method] (container: 'PieContainer', /, labels: 'str | Sequence[str]', *, distance: 'float' = 0.6, textprops: 'dict | None' = None, rotate: 'bool' = False, alignment: 'str' = 'auto') -> 'list[Text]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| stem() | 用基线、茎杆和节点表达离散值,不等于统计学茎叶表 | pyplot.stem [method] (*args: 'ArrayLike | str', linefmt: 'str | None' = None, markerfmt: 'str | None' = None, basefmt: 'str | None' = None, bottom: 'float' = 0, label: 'str | None' = None, orientation: "Literal['vertical', 'horizontal']" = 'vertical', data: 'DataParamType' = None) -> 'StemContainer' | 存在性和签名记录,不代表所有参数组合实际运行 |
| eventplot() | 把事件位置显示为平行短线集合 | pyplot.eventplot [method] (positions: 'ArrayLike | Sequence[ArrayLike]', *, orientation: "Literal['horizontal', 'vertical']" = 'horizontal', lineoffsets: 'float | Sequence[float]' = 1, linelengths: 'float | Sequence[float]' = 1, linewidths: 'float | Sequence[float] | None' = None, colors: 'ColorType | Sequence[ColorType] | None' = None, alpha: 'float | Sequence[float] | None' = None, linestyles: 'LineStyleType | Sequence[LineStyleType]' = 'solid', data: 'DataParamType' = None, **kwargs) -> 'EventCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| step() | 按pre/post/mid关系绘制阶梯连接 | pyplot.step [method] (x: 'ArrayLike', y: 'ArrayLike', *args, where: "Literal['pre', 'post', 'mid']" = 'pre', data: 'DataParamType' = None, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| fill() | 以坐标序列建立填充多边形 | pyplot.fill [method] (*args, data: 'DataParamType' = None, **kwargs) -> 'list[Polygon]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| fill_between() | 填充两条y(x)曲线之间区域,可按where选择 | pyplot.fill_between [method] (x: 'ArrayLike', y1: 'ArrayLike | float', y2: 'ArrayLike | float' = 0, where: 'ArrayLike | None' = None, interpolate: 'bool' = False, step: "Literal['pre', 'post', 'mid'] | None" = None, *, data: 'DataParamType' = None, **kwargs) -> 'FillBetweenPolyCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| fill_betweenx() | 填充两条x(y)曲线之间区域 | pyplot.fill_betweenx [method] (y: 'ArrayLike', x1: 'ArrayLike | float', x2: 'ArrayLike | float' = 0, where: 'ArrayLike | None' = None, step: "Literal['pre', 'post', 'mid'] | None" = None, interpolate: 'bool' = False, *, data: 'DataParamType' = None, **kwargs) -> 'FillBetweenPolyCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| stackplot() | 将多个非负等适用序列组织为堆叠面积,基线算法需明确 | pyplot.stackplot [method] (x, *args, labels=(), colors=None, baseline='zero', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| broken_barh() | 以起点长度区间画水平矩形集合 | pyplot.broken_barh [method] (xranges: 'Sequence[tuple[float, float]]', yrange: 'tuple[float, float]', align: "Literal['bottom', 'center', 'top']" = 'bottom', *, data: 'DataParamType' = None, **kwargs) -> 'PolyCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| vlines() | 在指定x位置绘制有界竖线段 | pyplot.vlines [method] (x: 'float | ArrayLike', ymin: 'float | ArrayLike', ymax: 'float | ArrayLike', colors: 'ColorType | Sequence[ColorType] | None' = None, linestyles: 'LineStyleType' = 'solid', *, label: 'str' = '', data: 'DataParamType' = None, **kwargs) -> 'LineCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| hlines() | 在指定y位置绘制有界横线段 | pyplot.hlines [method] (y: 'float | ArrayLike', xmin: 'float | ArrayLike', xmax: 'float | ArrayLike', colors: 'ColorType | Sequence[ColorType] | None' = None, linestyles: 'LineStyleType' = 'solid', *, label: 'str' = '', data: 'DataParamType' = None, **kwargs) -> 'LineCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| errorbar() | 将误差长度附在线点上,误差不自动代表置信区间 | pyplot.errorbar [method] (x: 'float | ArrayLike', y: 'float | ArrayLike', yerr: 'float | ArrayLike | None' = None, xerr: 'float | ArrayLike | None' = None, fmt: 'str' = '', *, ecolor: 'ColorType | None' = None, elinewidth: 'float | None' = None, capsize: 'float | None' = None, barsabove: 'bool' = False, lolims: 'bool | ArrayLike' = False, uplims: 'bool | ArrayLike' = False, xlolims: 'bool | ArrayLike' = False, xuplims: 'bool | ArrayLike' = False, errorevery: 'int | tuple[int, int]' = 1, capthick: 'float | None' = None, elinestyle: 'LineStyleType | None' = None, data: 'DataParamType' = None, **kwargs) -> 'ErrorbarContainer' | 存在性和签名记录,不代表所有参数组合实际运行 |
| loglog() | 同时把横纵轴设置为对数再绘制线 | pyplot.loglog [method] (*args, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| semilogx() | 把横轴设为对数后绘制线 | pyplot.semilogx [method] (*args, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| semilogy() | 把纵轴设为对数后绘制线 | pyplot.semilogy [method] (*args, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| polar() | 在极坐标投影中绘图,角度通常用弧度 | pyplot.polar [method] (*args, **kwargs) -> 'list[Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 4
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| axhline() | 用数据y值及轴比例横范围画水平参考线 | pyplot.axhline [method] (y: 'float' = 0, xmin: 'float' = 0, xmax: 'float' = 1, **kwargs) -> 'Line2D' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axhspan() | 按数据y范围和轴比例横范围画水平带 | pyplot.axhspan [method] (ymin: 'float', ymax: 'float', xmin: 'float' = 0, xmax: 'float' = 1, **kwargs) -> 'Rectangle' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axvline() | 用数据x值及轴比例纵范围画竖直参考线 | pyplot.axvline [method] (x: 'float' = 0, ymin: 'float' = 0, ymax: 'float' = 1, **kwargs) -> 'Line2D' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axvspan() | 按数据x范围和轴比例纵范围画竖直带 | pyplot.axvspan [method] (xmin: 'float', xmax: 'float', ymin: 'float' = 0, ymax: 'float' = 1, **kwargs) -> 'Rectangle' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axline() | 依据两点或点斜率建立无限延伸直线,比例变换有限制 | pyplot.axline [method] (xy1: 'tuple[float, float]', xy2: 'tuple[float, float] | None' = None, *, slope: 'float | None' = None, **kwargs) -> 'AxLine' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 5
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| acorr() | 计算并展示序列的自相关,归一化及最大lag需明确 | pyplot.acorr [method] (x: 'ArrayLike', *, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xcorr() | 计算两序列的互相关,不能直接推出因果或时延机制 | pyplot.xcorr [method] (x: 'ArrayLike', y: 'ArrayLike', *, normed: 'bool' = True, detrend: 'Callable[[ArrayLike], ArrayLike]' = <function detrend_none at 0x000002514C9FD080>, usevlines: 'bool' = True, maxlags: 'int' = 10, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| angle_spectrum() | 展示信号傅里叶结果的角度谱 | pyplot.angle_spectrum [method] (x: 'ArrayLike', *, Fs: 'float | None' = None, Fc: 'int | None' = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| magnitude_spectrum() | 展示信号幅度谱,尺度及采样频率需明确 | pyplot.magnitude_spectrum [method] (x: 'ArrayLike', *, Fs: 'float | None' = None, Fc: 'int | None' = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, scale: "Literal['default', 'linear', 'dB'] | None" = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| phase_spectrum() | 展示展开处理的相位谱,依当前接口定义 | pyplot.phase_spectrum [method] (x: 'ArrayLike', *, Fs: 'float | None' = None, Fc: 'int | None' = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| psd() | 按窗口和分段方法估计功率谱密度 | pyplot.psd [method] (x: 'ArrayLike', *, NFFT: 'int | None' = None, Fs: 'float | None' = None, Fc: 'int | None' = None, detrend: "Literal['none', 'mean', 'linear'] | Callable[[ArrayLike], ArrayLike] | None" = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, noverlap: 'int | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, scale_by_freq: 'bool | None' = None, return_line: 'bool | None' = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| csd() | 估计两信号的互功率谱密度 | pyplot.csd [method] (x: 'ArrayLike', y: 'ArrayLike', *, NFFT: 'int | None' = None, Fs: 'float | None' = None, Fc: 'int | None' = None, detrend: "Literal['none', 'mean', 'linear'] | Callable[[ArrayLike], ArrayLike] | None" = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, noverlap: 'int | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, scale_by_freq: 'bool | None' = None, return_line: 'bool | None' = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| cohere() | 估计频域相干性,不等同因果关系 | pyplot.cohere [method] (x: 'ArrayLike', y: 'ArrayLike', *, NFFT: 'int' = 256, Fs: 'float' = 2, Fc: 'int' = 0, detrend: "Literal['none', 'mean', 'linear'] | Callable[[ArrayLike], ArrayLike]" = <function detrend_none at 0x000002514C9FD080>, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike' = <function window_hanning at 0x000002514C9FC900>, noverlap: 'int' = 0, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided']" = 'default', scale_by_freq: 'bool | None' = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| specgram() | 按分段窗口形成时频谱图 | pyplot.specgram [method] (x: 'ArrayLike', *, NFFT: 'int | None' = None, Fs: 'float | None' = None, Fc: 'int | None' = None, detrend: "Literal['none', 'mean', 'linear'] | Callable[[ArrayLike], ArrayLike] | None" = None, window: 'Callable[[ArrayLike], ArrayLike] | ArrayLike | None' = None, noverlap: 'int | None' = None, cmap: 'str | Colormap | None' = None, xextent: 'tuple[float, float] | None' = None, pad_to: 'int | None' = None, sides: "Literal['default', 'onesided', 'twosided'] | None" = None, scale_by_freq: 'bool | None' = None, mode: "Literal['default', 'psd', 'magnitude', 'angle', 'phase'] | None" = None, scale: "Literal['default', 'linear', 'dB'] | None" = None, vmin: 'float | None' = None, vmax: 'float | None' = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 6
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| boxplot() | 依据分位数和须规则绘制箱线图,异常点不自动等于错误 | pyplot.boxplot [method] (x: 'ArrayLike | Sequence[ArrayLike]', *, notch: 'bool | None' = None, sym: 'str | None' = None, vert: 'bool | None' = None, orientation: "Literal['vertical', 'horizontal']" = 'vertical', whis: 'float | tuple[float, float] | None' = None, positions: 'ArrayLike | None' = None, widths: 'float | ArrayLike | None' = None, patch_artist: 'bool | None' = None, bootstrap: 'int | None' = None, usermedians: 'ArrayLike | None' = None, conf_intervals: 'ArrayLike | None' = None, meanline: 'bool | None' = None, showmeans: 'bool | None' = None, showcaps: 'bool | None' = None, showbox: 'bool | None' = None, showfliers: 'bool | None' = None, boxprops: 'dict[str, Any] | None' = None, tick_labels: 'Sequence[str] | None' = None, flierprops: 'dict[str, Any] | None' = None, medianprops: 'dict[str, Any] | None' = None, meanprops: 'dict[str, Any] | None' = None, capprops: 'dict[str, Any] | None' = None, whiskerprops: 'dict[str, Any] | None' = None, manage_ticks: 'bool' = True, autorange: 'bool' = False, zorder: 'float | None' = None, capwidths: 'float | ArrayLike | None' = None, label: 'Sequence[str] | None' = None, data: 'DataParamType' = None) -> 'dict[str, Any]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| violinplot() | 依据样本密度估计绘制小提琴外形 | pyplot.violinplot [method] (dataset: 'ArrayLike | Sequence[ArrayLike]', positions: 'ArrayLike | None' = None, *, vert: 'bool | None' = None, orientation: "Literal['vertical', 'horizontal']" = 'vertical', widths: 'float | ArrayLike' = 0.5, showmeans: 'bool' = False, showextrema: 'bool' = True, showmedians: 'bool' = False, quantiles: 'Sequence[float | Sequence[float]] | None' = None, points: 'int' = 100, bw_method: "Literal['scott', 'silverman'] | float | Callable[[GaussianKDE], float] | None" = None, side: "Literal['both', 'low', 'high']" = 'both', facecolor: 'Sequence[ColorType] | ColorType | None' = None, linecolor: 'Sequence[ColorType] | ColorType | None' = None, data: 'DataParamType' = None) -> 'dict[str, Collection]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ecdf() | 显示经验累积分布而非概率密度 | pyplot.ecdf [method] (x: 'ArrayLike', weights: 'ArrayLike | None' = None, *, complementary: 'bool' = False, orientation: "Literal['vertical', 'horizontal']" = 'vertical', compress: 'bool' = False, data: 'DataParamType' = None, **kwargs) -> 'Line2D' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 7
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| hist() | 按箱边界统计输入,返回频数或密度及图形对象 | pyplot.hist [method] (x: 'ArrayLike | Sequence[ArrayLike]', bins: 'int | Sequence[float] | str | None' = None, *, range: 'tuple[float, float] | None' = None, density: 'bool' = False, weights: 'ArrayLike | None' = None, cumulative: 'bool | float' = False, bottom: 'ArrayLike | float | None' = None, histtype: "Literal['bar', 'barstacked', 'step', 'stepfilled']" = 'bar', align: "Literal['left', 'mid', 'right']" = 'mid', orientation: "Literal['vertical', 'horizontal']" = 'vertical', rwidth: 'float | None' = None, log: 'bool' = False, color: 'ColorType | Sequence[ColorType] | None' = None, label: 'str | Sequence[str] | None' = None, stacked: 'bool' = False, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray | list[np.ndarray], np.ndarray, BarContainer | Polygon | list[BarContainer | Polygon]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| hist2d() | 对二维位置分箱计数或估计密度 | pyplot.hist2d [method] (x: 'ArrayLike', y: 'ArrayLike', bins: 'None | int | tuple[int, int] | ArrayLike | tuple[ArrayLike, ArrayLike]' = 10, *, range: 'ArrayLike | None' = None, density: 'bool' = False, weights: 'ArrayLike | None' = None, cmin: 'float | None' = None, cmax: 'float | None' = None, data: 'DataParamType' = None, **kwargs) -> 'tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| hexbin() | 以六边形单元聚合二维位置或关联数值 | pyplot.hexbin [method] (x: 'ArrayLike', y: 'ArrayLike', C: 'ArrayLike | None' = None, *, gridsize: 'int | tuple[int, int]' = 100, bins: "Literal['log'] | int | Sequence[float] | None" = None, xscale: "Literal['linear', 'log']" = 'linear', yscale: "Literal['linear', 'log']" = 'linear', extent: 'tuple[float, float, float, float] | None' = None, cmap: 'str | Colormap | None' = None, norm: 'str | Normalize | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, alpha: 'float | None' = None, linewidths: 'float | None' = None, edgecolors: "Literal['face', 'none'] | ColorType" = 'face', reduce_C_function: 'Callable[[np.ndarray | list[float]], float]' = <function mean at 0x000002514C625370>, mincnt: 'int | None' = None, marginals: 'bool' = False, colorizer: 'Colorizer | None' = None, data: 'DataParamType' = None, **kwargs) -> 'PolyCollection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| stairs() | 使用已知箱值与边界绘制阶梯,不能代替计算样本分箱 | pyplot.stairs [method] (values: 'ArrayLike', edges: 'ArrayLike | None' = None, *, orientation: "Literal['vertical', 'horizontal']" = 'vertical', baseline: 'float | ArrayLike | None' = 0, fill: 'bool' = False, data: 'DataParamType' = None, **kwargs) -> 'StepPatch' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 8
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| contour() | 在规则网格或适用输入上绘制等值线 | pyplot.contour [method] (*args, data: 'DataParamType' = None, **kwargs) -> 'QuadContourSet' | 存在性和签名记录,不代表所有参数组合实际运行 |
| contourf() | 填充相邻等值范围区域 | pyplot.contourf [method] (*args, data: 'DataParamType' = None, **kwargs) -> 'QuadContourSet' | 存在性和签名记录,不代表所有参数组合实际运行 |
| clabel() | 给已有等值线集合添加数值文字 | pyplot.clabel [method] (CS: 'ContourSet', levels: 'ArrayLike | None' = None, **kwargs) -> 'list[Text]' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 9
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| imshow() | 将规则像素数组映射到坐标系,返回AxesImage | pyplot.imshow [method] (X: 'ArrayLike | PIL.Image.Image', cmap: 'str | Colormap | None' = None, norm: 'str | Normalize | None' = None, *, aspect: "Literal['equal', 'auto'] | float | None" = None, interpolation: 'str | None' = None, alpha: 'float | ArrayLike | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, colorizer: 'Colorizer | None' = None, origin: "Literal['upper', 'lower'] | None" = None, extent: 'tuple[float, float, float, float] | None' = None, interpolation_stage: "Literal['data', 'rgba', 'auto'] | None" = None, filternorm: 'bool' = True, filterrad: 'float' = 4.0, resample: 'bool | None' = None, url: 'str | None' = None, data: 'DataParamType' = None, **kwargs) -> 'AxesImage' | 存在性和签名记录,不代表所有参数组合实际运行 |
| matshow() | 以适合矩阵的轴安排显示二维数组 | pyplot.matshow [method] (A: 'ArrayLike', fignum: 'None | int' = None, **kwargs) -> 'AxesImage' | 存在性和签名记录,不代表所有参数组合实际运行 |
| pcolor() | 用多边形色块表示网格,遮罩及边界语义需核对 | pyplot.pcolor [method] (*args: 'ArrayLike', shading: "Literal['flat', 'nearest', 'auto'] | None" = None, alpha: 'float | None' = None, norm: 'str | Normalize | None' = None, cmap: 'str | Colormap | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, colorizer: 'Colorizer | None' = None, data: 'DataParamType' = None, **kwargs) -> 'Collection' | 存在性和签名记录,不代表所有参数组合实际运行 |
| pcolormesh() | 以QuadMesh表达网格数据,坐标和shading决定形状关系 | pyplot.pcolormesh [method] (*args: 'ArrayLike', alpha: 'float | None' = None, norm: 'str | Normalize | None' = None, cmap: 'str | Colormap | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, colorizer: 'Colorizer | None' = None, shading: "Literal['flat', 'nearest', 'gouraud', 'auto'] | None" = None, antialiased: 'bool' = False, data: 'DataParamType' = None, **kwargs) -> 'QuadMesh' | 存在性和签名记录,不代表所有参数组合实际运行 |
| spy() | 显示矩阵非零位置或适用稀疏存储位置 | pyplot.spy [method] (Z: 'ArrayLike', *, precision: "float | Literal['present']" = 0, marker: 'str | None' = None, markersize: 'float | None' = None, aspect: "Literal['equal', 'auto'] | float | None" = 'equal', origin: "Literal['upper', 'lower']" = 'upper', **kwargs) -> 'AxesImage' | 存在性和签名记录,不代表所有参数组合实际运行 |
| figimage() | 在画布级放置像素图像,不创建普通Axes图像 | pyplot.figimage [method] (X: 'ArrayLike', xo: 'int' = 0, yo: 'int' = 0, alpha: 'float | None' = None, norm: 'str | Normalize | None' = None, cmap: 'str | Colormap | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, origin: "Literal['upper', 'lower'] | None" = None, resize: 'bool' = False, *, colorizer: 'Colorizer | None' = None, **kwargs) -> 'FigureImage' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 10
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| triplot() | 显示非结构化三角剖分的边及可选节点 | pyplot.triplot [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| tripcolor() | 对三角网格的节点或面进行伪彩色表示 | pyplot.tripcolor [method] (*args, alpha=1.0, norm=None, cmap=None, vmin=None, vmax=None, shading='flat', facecolors=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| tricontour() | 在三角网格上绘制等值线 | pyplot.tricontour [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| tricontourf() | 填充三角网格的等值区间 | pyplot.tricontourf [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 11
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| text() | 在给定坐标及变换中放置文字 | pyplot.text [method] (x: 'float', y: 'float', s: 'str', fontdict: 'dict[str, Any] | None' = None, **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| figtext() | 在Figure级放置文字,默认坐标变换不同于Axes.text | pyplot.figtext [method] (x: 'float', y: 'float', s: 'str', fontdict: 'dict[str, Any] | None' = None, **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| annotate() | 以目标点与可选箭头添加注释,xycoords等控制坐标语义 | pyplot.annotate [method] (text: 'str', xy: 'tuple[Any, Any]', xytext: 'tuple[Any, Any] | None' = None, xycoords: 'CoordsType' = 'data', textcoords: 'CoordsType | None' = None, arrowprops: 'dict[str, Any] | None' = None, annotation_clip: 'bool | None' = None, **kwargs) -> 'Annotation' | 存在性和签名记录,不代表所有参数组合实际运行 |
| arrow() | 用几何尺寸建立箭头补丁,轴比例可能改变外观 | pyplot.arrow [method] (x: 'float', y: 'float', dx: 'float', dy: 'float', **kwargs) -> 'FancyArrow' | 存在性和签名记录,不代表所有参数组合实际运行 |
| legend() | 为带标签图形建立图例,不自动推断业务含义 | pyplot.legend [method] (*args, **kwargs) -> 'Legend' | 存在性和签名记录,不代表所有参数组合实际运行 |
| figlegend() | 在Figure级组织跨坐标系图例 | pyplot.figlegend [method] (*args, **kwargs) -> 'Legend' | 存在性和签名记录,不代表所有参数组合实际运行 |
| table() | 把二维单元格文字组织为绘图表格对象 | pyplot.table [method] (cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None, edges='closed', **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 12
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| quiver() | 把二维向量的方向和尺度显示为箭头 | pyplot.quiver [method] (*args, data: 'DataParamType' = None, **kwargs) -> 'Quiver' | 存在性和签名记录,不代表所有参数组合实际运行 |
| quiverkey() | 为已有quiver对象增加量值参考箭头 | pyplot.quiverkey [method] (Q: 'Quiver', X: 'float', Y: 'float', U: 'float', label: 'str', **kwargs) -> 'QuiverKey' | 存在性和签名记录,不代表所有参数组合实际运行 |
| barbs() | 以气象风羽符号表达向量分量 | pyplot.barbs [method] (*args, data: 'DataParamType' = None, **kwargs) -> 'Barbs' | 存在性和签名记录,不代表所有参数组合实际运行 |
| streamplot() | 根据适用规则网格向量场绘制流线 | pyplot.streamplot [method] (x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, transform=None, zorder=None, start_points=None, maxlength=4.0, integration_direction='both', broken_streamlines=True, *, integration_max_step_scale=1.0, integration_max_error_scale=1.0, num_arrows=1, data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 13
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| title() | 设置当前Axes标题,不是整个Figure总标题 | pyplot.title [method] (label: 'str', fontdict: 'dict[str, Any] | None' = None, loc: "Literal['left', 'center', 'right'] | None" = None, pad: 'float | None' = None, *, y: 'float | None' = None, **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| suptitle() | 设置Figure或SubFigure的总标题 | pyplot.suptitle [method] (t: 'str', **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xlabel() | 设置当前坐标系横轴说明文字 | pyplot.xlabel [method] (xlabel: 'str', fontdict: 'dict[str, Any] | None' = None, labelpad: 'float | None' = None, *, loc: "Literal['left', 'center', 'right'] | None" = None, **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ylabel() | 设置当前坐标系纵轴说明文字 | pyplot.ylabel [method] (ylabel: 'str', fontdict: 'dict[str, Any] | None' = None, labelpad: 'float | None' = None, *, loc: "Literal['bottom', 'center', 'top'] | None" = None, **kwargs) -> 'Text' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xlim() | 读取或设置横轴数据视图范围 | pyplot.xlim [method] (*args, **kwargs) -> 'tuple[float, float]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ylim() | 读取或设置纵轴数据视图范围 | pyplot.ylim [method] (*args, **kwargs) -> 'tuple[float, float]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xscale() | 指定横轴尺度类型及相应变换参数 | pyplot.xscale [method] (value: 'str | ScaleBase', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| yscale() | 指定纵轴尺度类型及相应变换参数 | pyplot.yscale [method] (value: 'str | ScaleBase', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xticks() | 读取或设置横轴刻度位置及相应文字 | pyplot.xticks [method] (ticks: 'ArrayLike | None' = None, labels: 'Sequence[str] | None' = None, *, minor: 'bool' = False, **kwargs) -> 'tuple[list[Tick] | np.ndarray, list[Text]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| yticks() | 读取或设置纵轴刻度位置及相应文字 | pyplot.yticks [method] (ticks: 'ArrayLike | None' = None, labels: 'Sequence[str] | None' = None, *, minor: 'bool' = False, **kwargs) -> 'tuple[list[Tick] | np.ndarray, list[Text]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| tick_params() | 设置刻度与标签方向、长度、颜色等属性 | pyplot.tick_params [method] (axis: "Literal['both', 'x', 'y']" = 'both', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ticklabel_format() | 配置ScalarFormatter数值显示,需对应formatter支持 | pyplot.ticklabel_format [method] (*, axis: "Literal['both', 'x', 'y']" = 'both', style: "Literal['', 'sci', 'scientific', 'plain'] | None" = None, scilimits: 'tuple[int, int] | None' = None, useOffset: 'bool | float | None' = None, useLocale: 'bool | None' = None, useMathText: 'bool | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| locator_params() | 调整刻度定位器的支持参数,不能套任意键 | pyplot.locator_params [method] (axis: "Literal['both', 'x', 'y']" = 'both', tight: 'bool | None' = None, **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| minorticks_on() | 为当前尺度安装适用的次刻度定位器 | pyplot.minorticks_on [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| minorticks_off() | 关闭次刻度定位 | pyplot.minorticks_off [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| rgrids() | 在极坐标系设置径向刻度网格及标签 | pyplot.rgrids [method] (radii: 'ArrayLike | None' = None, labels: 'Sequence[str | Text] | None' = None, angle: 'float | None' = None, fmt: 'str | None' = None, **kwargs) -> 'tuple[list[Line2D], list[Text]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| thetagrids() | 在极坐标系设置角度网格及标签 | pyplot.thetagrids [method] (angles: 'ArrayLike | None' = None, labels: 'Sequence[str | Text] | None' = None, fmt: 'str | None' = None, **kwargs) -> 'tuple[list[Line2D], list[Text]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| grid() | 配置主次网格显隐和样式,None无样式时会切换 | pyplot.grid [method] (visible: 'bool | None' = None, which: "Literal['major', 'minor', 'both']" = 'major', axis: "Literal['both', 'x', 'y']" = 'both', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| axis() | 便捷读取或配置范围、比例及轴可见状态 | pyplot.axis [method] (arg: 'tuple[float, float, float, float] | bool | str | None' = None, /, *, emit: 'bool' = True, **kwargs) -> 'tuple[float, float, float, float]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| box() | 切换或设置坐标系外框显示 | pyplot.box [method] (on: 'bool | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| autoscale() | 根据数据及开关配置自动调整视图范围 | pyplot.autoscale [method] (enable: 'bool' = True, axis: "Literal['both', 'x', 'y']" = 'both', tight: 'bool | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 14
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| subplots_adjust() | 手动设置子图与画布边距及子图间隔 | pyplot.subplots_adjust [method] (left: 'float | None' = None, bottom: 'float | None' = None, right: 'float | None' = None, top: 'float | None' = None, wspace: 'float | None' = None, hspace: 'float | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| tight_layout() | 基于文字等边界调整布局;优先考虑创建时constrained布局 | pyplot.tight_layout [method] (*, pad: 'float' = 1.08, h_pad: 'float | None' = None, w_pad: 'float | None' = None, rect: 'tuple[float, float, float, float] | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| margins() | 设置或读取数据限外的比例边距 | pyplot.margins [method] (*margins: 'float', x: 'float | None' = None, y: 'float | None' = None, tight: 'bool | None' = True) -> 'tuple[float, float] | None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| subplot_tool() | 启动依赖交互后端的子图布局工具 | pyplot.subplot_tool [method] (targetfig: 'Figure | None' = None) -> 'SubplotTool | None' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 15
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| colorbar() | 为明确的ScalarMappable添加颜色条 | pyplot.colorbar [method] (mappable: 'ScalarMappable | ColorizingArtist | None' = None, cax: 'matplotlib.axes.Axes | None' = None, ax: 'matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None' = None, **kwargs) -> 'Colorbar' | 存在性和签名记录,不代表所有参数组合实际运行 |
| clim() | 设置当前可映射颜色对象的数值范围 | pyplot.clim [method] (vmin: 'float | None' = None, vmax: 'float | None' = None) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| get_cmap() | 取得命名颜色映射或当前默认色图 | pyplot.get_cmap [method] (name: 'Colormap | str | None' = None, lut: 'int | None' = None) -> 'Colormap' | 存在性和签名记录,不代表所有参数组合实际运行 |
| set_cmap() | 选择后续图像等使用的默认颜色映射 | pyplot.set_cmap [method] (cmap: 'Colormap | str') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| gci() | 取得pyplot当前可映射颜色对象 | pyplot.gci [method] () -> 'ColorizingArtist | None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| sci() | 选择pyplot当前可映射颜色对象 | pyplot.sci [method] (im: 'ColorizingArtist') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| imread() | 解码图像为数组,形状及dtype由格式决定 | pyplot.imread [method] (fname: 'str | pathlib.Path | BinaryIO', format: 'str | None' = None) -> 'np.ndarray' | 存在性和签名记录,不代表所有参数组合实际运行 |
| imsave() | 把像素数组编码到文件,不包含整张Figure的标题和轴 | pyplot.imsave [method] (fname: 'str | os.PathLike | BinaryIO', arr: 'ArrayLike', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| colormaps | 已注册色图的访问注册表 | pyplot.colormaps [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| color_sequences | 已注册颜色序列的访问注册表 | pyplot.color_sequences [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 16
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| rc() | 批量修改rcParams配置 | pyplot.rc [method] (group: 'RcGroupKeyType', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| rc_context() | 在作用域中临时修改配置并在退出后恢复 | pyplot.rc_context [method] (rc: 'dict[RcKeyType, Any] | None' = None, fname: 'str | pathlib.Path | os.PathLike | None' = None) -> 'AbstractContextManager[None]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| rcdefaults() | 恢复Matplotlib默认配置,可能改变后续全局绘图 | pyplot.rcdefaults [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 17
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| show() | 请求当前后端展示已管理图形,Agg不产生GUI窗口 | pyplot.show [method] (*, block=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| savefig() | 保存当前画布或相应对象图形,格式与DPI显式管理 | pyplot.savefig [method] (fname: 'str | os.PathLike | IO', **kwargs) -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| draw() | 请求当前图形渲染,属于画布/renderer层而非数据计算 | pyplot.draw [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| draw_if_interactive() | 在交互模式条件满足时安排重绘 | pyplot.draw_if_interactive [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| pause() | 短暂处理GUI事件循环并等待,不等于精确实时调度 | pyplot.pause [method] (interval: 'float') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ion() | 开启pyplot交互模式,不保证无GUI后端出现窗口 | pyplot.ion [method] () -> 'AbstractContextManager' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ioff() | 关闭pyplot交互模式 | pyplot.ioff [method] () -> 'AbstractContextManager' | 存在性和签名记录,不代表所有参数组合实际运行 |
| isinteractive() | 读取交互模式状态,不等于GUI事件循环正在正常运行 | pyplot.isinteractive [method] () -> 'bool' | 存在性和签名记录,不代表所有参数组合实际运行 |
| install_repl_displayhook() | 为交互解释器安装自动显示钩子 | pyplot.install_repl_displayhook [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| uninstall_repl_displayhook() | 移除对应自动显示钩子 | pyplot.uninstall_repl_displayhook [method] () -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| switch_backend() | 切换后端,现有事件循环和窗口资源条件需考虑 | pyplot.switch_backend [method] (newbackend: 'str') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 18
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| connect() | 在当前画布上注册事件回调并返回连接编号 | pyplot.connect [method] (s, func) -> 'int' | 存在性和签名记录,不代表所有参数组合实际运行 |
| disconnect() | 按连接编号移除当前画布事件回调 | pyplot.disconnect [method] (cid: 'int') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| ginput() | 通过真实GUI交互取得点坐标,Agg无法代替鼠标操作 | pyplot.ginput [method] (n: 'int' = 1, timeout: 'float' = 30, show_clicks: 'bool' = True, mouse_add: 'MouseButton' = <MouseButton.LEFT: 1>, mouse_pop: 'MouseButton' = <MouseButton.RIGHT: 3>, mouse_stop: 'MouseButton' = <MouseButton.MIDDLE: 2>) -> 'list[tuple[int, int]]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| waitforbuttonpress() | 等待GUI键盘或鼠标事件,超时与返回值需区分 | pyplot.waitforbuttonpress [method] (timeout: 'float' = -1) -> 'None | bool' | 存在性和签名记录,不代表所有参数组合实际运行 |
| findobj() | 遍历Artist树并按条件查找对象 | pyplot.findobj [method] (o: 'Artist | None' = None, match: 'Callable[[Artist], bool] | type[Artist] | None' = None, include_self: 'bool' = True) -> 'list[Artist]' | 存在性和签名记录,不代表所有参数组合实际运行 |
| get() | 读取Artist属性的别名接口,与getp对应 | pyplot.get [method] (obj, *args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| getp() | 查询Artist属性,未给名称时可能打印而非只返回字典 | pyplot.getp [method] (obj, *args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| setp() | 设置一个或多个Artist属性,支持属性名称和值 | pyplot.setp [method] (obj, *args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| get_current_fig_manager() | 取得当前画布管理器,不等于底层Figure | pyplot.get_current_fig_manager [method] () -> 'FigureManagerBase | None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| new_figure_manager() | 为后端创建新的画布管理器 | pyplot.new_figure_manager [method] (num, *args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| set_loglevel() | 设置Matplotlib日志级别,与业务日志分开 | pyplot.set_loglevel [method] (level: 'LogLevel') -> 'None' | 存在性和签名记录,不代表所有参数组合实际运行 |
| xkcd() | 临时配置手绘漫画外观,所需字体可能不存在 | pyplot.xkcd [method] (scale: 'float' = 1, length: 'float' = 100, randomness: 'float' = 2) -> 'ExitStack' | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 19
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.plot() | 按输入顺序绘制二维线及可选标记,返回Line2D集合 | Axes.plot [method] (*args, scalex=True, scaley=True, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.scatter() | 以位置、面积及颜色映射创建PathCollection | Axes.scatter [method] (x, y, s=None, c=None, *, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors=None, colorizer=None, plotnonfinite=False, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.bar() | 绘制竖柱,bottom控制底座,width控制厚度 | Axes.bar [method] (x, height, width=0.8, bottom=None, *, align='center', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.barh() | 绘制横条,left控制起点,height控制厚度 | Axes.barh [method] (y, width, height=0.8, left=None, *, align='center', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.bar_label() | 在BarContainer条柱对应端点或中心放置文字 | Axes.bar_label [method] (container, labels=None, *, fmt='%g', label_type='edge', padding=0, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.grouped_bar() | 按系列组织成分组柱图;属于当前3.11接口,旧环境需迁移 | Axes.grouped_bar [method] (heights, *, positions=None, group_spacing=1.5, bar_spacing=0, tick_labels=None, labels=None, orientation='vertical', colors=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pie() | 把非负组成数据映射为扇形,当前返回PieContainer | Axes.pie [method] (x, *, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=0, radius=1, counterclock=True, wedgeprops=None, textprops=None, center=(0, 0), frame=False, rotatelabels=False, normalize=True, hatch=None, data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pie_label() | 为饼图容器添加标签;需匹配当前版本接口 | Axes.pie_label [method] (container, /, labels, *, distance=0.6, textprops=None, rotate=False, alignment='auto') | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.stem() | 用基线、茎杆和节点表达离散值,不等于统计学茎叶表 | Axes.stem [method] (*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label=None, orientation='vertical', data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.eventplot() | 把事件位置显示为平行短线集合 | Axes.eventplot [method] (positions, *, orientation='horizontal', lineoffsets=1, linelengths=1, linewidths=None, colors=None, alpha=None, linestyles='solid', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.step() | 按pre/post/mid关系绘制阶梯连接 | Axes.step [method] (x, y, *args, where='pre', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.fill() | 以坐标序列建立填充多边形 | Axes.fill [method] (*args, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.fill_between() | 填充两条y(x)曲线之间区域,可按where选择 | Axes.fill_between [method] (x, y1, y2=0, where=None, interpolate=False, step=None, *, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.fill_betweenx() | 填充两条x(y)曲线之间区域 | Axes.fill_betweenx [method] (y, x1, x2=0, where=None, step=None, interpolate=False, *, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.stackplot() | 将多个非负等适用序列组织为堆叠面积,基线算法需明确 | Axes.stackplot [method] (x, *args, labels=(), colors=None, baseline='zero', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.broken_barh() | 以起点长度区间画水平矩形集合 | Axes.broken_barh [method] (xranges, yrange, align='bottom', *, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.vlines() | 在指定x位置绘制有界竖线段 | Axes.vlines [method] (x, ymin, ymax, colors=None, linestyles='solid', *, label='', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.hlines() | 在指定y位置绘制有界横线段 | Axes.hlines [method] (y, xmin, xmax, colors=None, linestyles='solid', *, label='', data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.errorbar() | 将误差长度附在线点上,误差不自动代表置信区间 | Axes.errorbar [method] (x, y, yerr=None, xerr=None, fmt='', *, ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, elinestyle=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.loglog() | 同时把横纵轴设置为对数再绘制线 | Axes.loglog [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.semilogx() | 把横轴设为对数后绘制线 | Axes.semilogx [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.semilogy() | 把纵轴设为对数后绘制线 | Axes.semilogy [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 20
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.axhline() | 用数据y值及轴比例横范围画水平参考线 | Axes.axhline [method] (y=0, xmin=0, xmax=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.axvline() | 用数据x值及轴比例纵范围画竖直参考线 | Axes.axvline [method] (x=0, ymin=0, ymax=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.axhspan() | 按数据y范围和轴比例横范围画水平带 | Axes.axhspan [method] (ymin, ymax, xmin=0, xmax=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.axvspan() | 按数据x范围和轴比例纵范围画竖直带 | Axes.axvspan [method] (xmin, xmax, ymin=0, ymax=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.axline() | 依据两点或点斜率建立无限延伸直线,比例变换有限制 | Axes.axline [method] (xy1, xy2=None, *, slope=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 21
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.acorr() | 计算并展示序列的自相关,归一化及最大lag需明确 | Axes.acorr [method] (x, *, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.xcorr() | 计算两序列的互相关,不能直接推出因果或时延机制 | Axes.xcorr [method] (x, y, *, normed=True, detrend=<function detrend_none at 0x000002514C9FD080>, usevlines=True, maxlags=10, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.angle_spectrum() | 展示信号傅里叶结果的角度谱 | Axes.angle_spectrum [method] (x, *, Fs=None, Fc=None, window=None, pad_to=None, sides=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.magnitude_spectrum() | 展示信号幅度谱,尺度及采样频率需明确 | Axes.magnitude_spectrum [method] (x, *, Fs=None, Fc=None, window=None, pad_to=None, sides=None, scale=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.phase_spectrum() | 展示展开处理的相位谱,依当前接口定义 | Axes.phase_spectrum [method] (x, *, Fs=None, Fc=None, window=None, pad_to=None, sides=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.psd() | 按窗口和分段方法估计功率谱密度 | Axes.psd [method] (x, *, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, return_line=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.csd() | 估计两信号的互功率谱密度 | Axes.csd [method] (x, y, *, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, return_line=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.cohere() | 估计频域相干性,不等同因果关系 | Axes.cohere [method] (x, y, *, NFFT=256, Fs=2, Fc=0, detrend=<function detrend_none at 0x000002514C9FD080>, window=<function window_hanning at 0x000002514C9FC900>, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.specgram() | 按分段窗口形成时频谱图 | Axes.specgram [method] (x, *, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, cmap=None, xextent=None, pad_to=None, sides=None, scale_by_freq=None, mode=None, scale=None, vmin=None, vmax=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 22
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.boxplot() | 依据分位数和须规则绘制箱线图,异常点不自动等于错误 | Axes.boxplot [method] (x, *, notch=None, sym=None, vert=None, orientation='vertical', whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, tick_labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_ticks=True, autorange=False, zorder=None, capwidths=None, label=None, data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.bxp() | 依据预先计算的统计字典绘制箱线图 | Axes.bxp [method] (bxpstats, positions=None, *, widths=None, vert=None, orientation='vertical', patch_artist=False, shownotches=False, showmeans=False, showcaps=True, showbox=True, showfliers=True, boxprops=None, whiskerprops=None, flierprops=None, medianprops=None, capprops=None, meanprops=None, meanline=False, manage_ticks=True, zorder=None, capwidths=None, label=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.violinplot() | 依据样本密度估计绘制小提琴外形 | Axes.violinplot [method] (dataset, positions=None, *, vert=None, orientation='vertical', widths=0.5, showmeans=False, showextrema=True, showmedians=False, quantiles=None, points=100, bw_method=None, side='both', facecolor=None, linecolor=None, data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.violin() | 依据预计算密度与统计结果绘制小提琴 | Axes.violin [method] (vpstats, positions=None, *, vert=None, orientation='vertical', widths=0.5, showmeans=False, showextrema=True, showmedians=False, side='both', facecolor=None, linecolor=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.ecdf() | 显示经验累积分布而非概率密度 | Axes.ecdf [method] (x, weights=None, *, complementary=False, orientation='vertical', compress=False, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 23
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.hist() | 按箱边界统计输入,返回频数或密度及图形对象 | Axes.hist [method] (x, bins=None, *, range=None, density=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.hist2d() | 对二维位置分箱计数或估计密度 | Axes.hist2d [method] (x, y, bins=10, *, range=None, density=False, weights=None, cmin=None, cmax=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.hexbin() | 以六边形单元聚合二维位置或关联数值 | Axes.hexbin [method] (x, y, C=None, *, gridsize=100, bins=None, xscale='linear', yscale='linear', extent=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors='face', reduce_C_function=<function mean at 0x000002514C625370>, mincnt=None, marginals=False, colorizer=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.stairs() | 使用已知箱值与边界绘制阶梯,不能代替计算样本分箱 | Axes.stairs [method] (values, edges=None, *, orientation='vertical', baseline=0, fill=False, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 24
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.contour() | 在规则网格或适用输入上绘制等值线 | Axes.contour [method] (*args, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.contourf() | 填充相邻等值范围区域 | Axes.contourf [method] (*args, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.clabel() | 给已有等值线集合添加数值文字 | Axes.clabel [method] (CS, levels=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 25
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.imshow() | 将规则像素数组映射到坐标系,返回AxesImage | Axes.imshow [method] (X, cmap=None, norm=None, *, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, colorizer=None, origin=None, extent=None, interpolation_stage=None, filternorm=True, filterrad=4.0, resample=None, url=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.matshow() | 以适合矩阵的轴安排显示二维数组 | Axes.matshow [method] (Z, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pcolor() | 用多边形色块表示网格,遮罩及边界语义需核对 | Axes.pcolor [method] (*args, shading=None, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, colorizer=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pcolorfast() | 依据矩形网格选择合适快速表示,不保证永远返回同类Artist | Axes.pcolorfast [method] (*args, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, colorizer=None, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pcolormesh() | 以QuadMesh表达网格数据,坐标和shading决定形状关系 | Axes.pcolormesh [method] (*args, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, colorizer=None, shading=None, antialiased=False, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.spy() | 显示矩阵非零位置或适用稀疏存储位置 | Axes.spy [method] (Z, *, precision=0, marker=None, markersize=None, aspect='equal', origin='upper', **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 26
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.triplot() | 显示非结构化三角剖分的边及可选节点 | Axes.triplot [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.tripcolor() | 对三角网格的节点或面进行伪彩色表示 | Axes.tripcolor [method] (*args, alpha=1.0, norm=None, cmap=None, vmin=None, vmax=None, shading='flat', facecolors=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.tricontour() | 在三角网格上绘制等值线 | Axes.tricontour [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.tricontourf() | 填充三角网格的等值区间 | Axes.tricontourf [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 27
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.text() | 在给定坐标及变换中放置文字 | Axes.text [method] (x, y, s, fontdict=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.annotate() | 以目标点与可选箭头添加注释,xycoords等控制坐标语义 | Axes.annotate [method] (text, xy, xytext=None, xycoords='data', textcoords=None, arrowprops=None, annotation_clip=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.table() | 把二维单元格文字组织为绘图表格对象 | Axes.table [method] (cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None, edges='closed', **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.arrow() | 用几何尺寸建立箭头补丁,轴比例可能改变外观 | Axes.arrow [method] (x, y, dx, dy, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.inset_axes() | 在父Axes内按相对位置建立嵌入坐标系 | Axes.inset_axes [method] (bounds, *, transform=None, zorder=5, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.indicate_inset() | 在父坐标系上标示指定嵌入区域 | Axes.indicate_inset [method] (bounds=None, inset_ax=None, *, transform=None, facecolor='none', edgecolor='0.5', alpha=0.5, zorder=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.indicate_inset_zoom() | 根据嵌入坐标系视图标示放大范围与连接 | Axes.indicate_inset_zoom [method] (inset_ax, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.secondary_xaxis() | 用可逆转换函数设置辅助横轴,不是独立数据双轴 | Axes.secondary_xaxis [method] (location, functions=None, *, transform=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.secondary_yaxis() | 用可逆转换函数设置辅助纵轴 | Axes.secondary_yaxis [method] (location, functions=None, *, transform=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 28
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.quiver() | 把二维向量的方向和尺度显示为箭头 | Axes.quiver [method] (*args, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.quiverkey() | 为已有quiver对象增加量值参考箭头 | Axes.quiverkey [method] (Q, X, Y, U, label, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.barbs() | 以气象风羽符号表达向量分量 | Axes.barbs [method] (*args, data=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.streamplot() | 根据适用规则网格向量场绘制流线 | Axes.streamplot [method] (x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, transform=None, zorder=None, start_points=None, maxlength=4.0, integration_direction='both', broken_streamlines=True, *, integration_max_step_scale=1.0, integration_max_error_scale=1.0, num_arrows=1, data=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 29
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.cla() | 清除一个坐标系内容与相应设置,不关闭整个画布 | Axes.cla [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.clear() | 清空当前容器内容;Figure与Axes的作用范围不同 | Axes.clear [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 30
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.axis() | 便捷读取或配置范围、比例及轴可见状态 | Axes.axis [method] (arg=None, /, *, emit=True, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_axis_off() | 隐藏整个坐标轴装饰,不删除数据Artist | Axes.set_axis_off [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_axis_on() | 恢复坐标轴装饰显示 | Axes.set_axis_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_frame_on() | 设置Axes外框显示开关;需在对应对象层级使用 | Axes.set_frame_on [method] (b) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_frame_on() | 读取Axes外框显示开关;需在对应对象层级使用 | Axes.get_frame_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_axisbelow() | 设置轴网格与刻度相对数据的层级;需在对应对象层级使用 | Axes.set_axisbelow [method] (b) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_axisbelow() | 读取轴网格与刻度相对数据的层级;需在对应对象层级使用 | Axes.get_axisbelow [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.grid() | 配置主次网格显隐和样式,None无样式时会切换 | Axes.grid [method] (visible=None, which='major', axis='both', **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_facecolor() | 读取容器背景颜色;需在对应对象层级使用 | Axes.get_facecolor [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_facecolor() | 设置容器背景颜色;需在对应对象层级使用 | Axes.set_facecolor [method] (color) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 31
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_prop_cycle() | 指定后续Artist属性循环,需各序列长度兼容 | Axes.set_prop_cycle [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 32
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.xaxis / Axes.yaxis | 横轴Axis对象;纵轴Axis对象 | Axes.xaxis [attribute] 无可调用签名;Axes.yaxis [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xaxis() / get_yaxis() | 读取横轴Axis对象;需在对应对象层级使用;读取纵轴Axis对象;需在对应对象层级使用 | Axes.get_xaxis [method] ();Axes.get_yaxis [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 33
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_xlim() / get_xlim() | 设置横轴视图范围;需在对应对象层级使用;读取横轴视图范围;需在对应对象层级使用 | Axes.set_xlim [method] (left=None, right=None, *, emit=True, auto=False, xmin=None, xmax=None);Axes.get_xlim [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_ylim() / get_ylim() | 设置纵轴视图范围;需在对应对象层级使用;读取纵轴视图范围;需在对应对象层级使用 | Axes.set_ylim [method] (bottom=None, top=None, *, emit=True, auto=False, ymin=None, ymax=None);Axes.get_ylim [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_xbound() / get_xbound() | 设置横轴上下界;需在对应对象层级使用;读取横轴上下界;需在对应对象层级使用 | Axes.set_xbound [method] (lower=None, upper=None);Axes.get_xbound [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_ybound() / get_ybound() | 设置纵轴上下界;需在对应对象层级使用;读取纵轴上下界;需在对应对象层级使用 | Axes.set_ybound [method] (lower=None, upper=None);Axes.get_ybound [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.invert_xaxis() | 切换横轴方向 | Axes.invert_xaxis [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.invert_yaxis() | 切换纵轴方向 | Axes.invert_yaxis [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.xaxis_inverted() / yaxis_inverted() | 读取横轴当前是否反向;读取纵轴当前是否反向 | Axes.xaxis_inverted [method] ();Axes.yaxis_inverted [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_xinverted() / get_xinverted() | 设置横轴反向开关;需在对应对象层级使用;读取横轴反向开关;需在对应对象层级使用 | Axes.set_xinverted [method] (inverted);Axes.get_xinverted [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_yinverted() / get_yinverted() | 设置纵轴反向开关;需在对应对象层级使用;读取纵轴反向开关;需在对应对象层级使用 | Axes.set_yinverted [method] (inverted);Axes.get_yinverted [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.update_datalim() | 用点集扩展数据范围,不自动等于已经更新视图 | Axes.update_datalim [method] (xys, updatex=True, updatey=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 34
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_xlabel() / get_xlabel() | 设置横轴说明文字;需在对应对象层级使用;读取横轴说明文字;需在对应对象层级使用 | Axes.set_xlabel [method] (xlabel, fontdict=None, labelpad=None, *, loc=None, **kwargs);Axes.get_xlabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_ylabel() / get_ylabel() | 设置纵轴说明文字;需在对应对象层级使用;读取纵轴说明文字;需在对应对象层级使用 | Axes.set_ylabel [method] (ylabel, fontdict=None, labelpad=None, *, loc=None, **kwargs);Axes.get_ylabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.label_outer() | 在子图网格保留外侧刻度标签 | Axes.label_outer [method] (remove_inner_ticks=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_title() / get_title() | 设置坐标系标题;需在对应对象层级使用;读取坐标系标题;需在对应对象层级使用 | Axes.set_title [method] (label, fontdict=None, loc=None, pad=None, *, y=None, **kwargs);Axes.get_title [method] (loc='center') | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.legend() | 为带标签图形建立图例,不自动推断业务含义 | Axes.legend [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_legend() | 取得已存在图例对象,尚未建立时可能None | Axes.get_legend [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_legend_handles_labels() | 取得可用于图例的句柄与标签 | Axes.get_legend_handles_labels [method] (legend_handler_map=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 35
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_xscale() / get_xscale() | 设置横轴尺度;需在对应对象层级使用;读取横轴尺度;需在对应对象层级使用 | Axes.set_xscale [method] (value, **kwargs);Axes.get_xscale [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_yscale() / get_yscale() | 设置纵轴尺度;需在对应对象层级使用;读取纵轴尺度;需在对应对象层级使用 | Axes.set_yscale [method] (value, **kwargs);Axes.get_yscale [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 36
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.autoscale() | 根据数据及开关配置自动调整视图范围 | Axes.autoscale [method] (enable=True, axis='both', tight=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.autoscale_view() | 根据已有数据范围更新视图,边距和tight选项另行控制 | Axes.autoscale_view [method] (tight=None, scalex=True, scaley=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.margins() | 设置或读取数据限外的比例边距 | Axes.margins [method] (*margins, x=None, y=None, tight=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.relim() | 根据适用Artist重新计算数据范围,集合等限制需另核对 | Axes.relim [method] (visible_only=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.use_sticky_edges() | 是否使用Artist粘性边界,布尔属性而非方法 | Axes.use_sticky_edges [attribute] 无可调用签名 | 准确属性,无括号;读取/赋值,不是鼠标命中或普通方法 |
| Axes.set_xmargin() / get_xmargin() | 设置横轴数据边距;需在对应对象层级使用;读取横轴数据边距;需在对应对象层级使用 | Axes.set_xmargin [method] (m);Axes.get_xmargin [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_ymargin() / get_ymargin() | 设置纵轴数据边距;需在对应对象层级使用;读取纵轴数据边距;需在对应对象层级使用 | Axes.set_ymargin [method] (m);Axes.get_ymargin [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_autoscale_on() / get_autoscale_on() | 设置双轴自动缩放开关;需在对应对象层级使用;读取双轴自动缩放开关;需在对应对象层级使用 | Axes.set_autoscale_on [method] (b);Axes.get_autoscale_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_autoscalex_on() / get_autoscalex_on() | 设置横轴自动缩放开关;需在对应对象层级使用;读取横轴自动缩放开关;需在对应对象层级使用 | Axes.set_autoscalex_on [method] (b);Axes.get_autoscalex_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_autoscaley_on() / get_autoscaley_on() | 设置纵轴自动缩放开关;需在对应对象层级使用;读取纵轴自动缩放开关;需在对应对象层级使用 | Axes.set_autoscaley_on [method] (b);Axes.get_autoscaley_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 37
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_aspect() / get_aspect() | 设置数据单位纵横比;需在对应对象层级使用;读取数据单位纵横比;需在对应对象层级使用 | Axes.set_aspect [method] (aspect, adjustable=None, anchor=None, share=False);Axes.get_aspect [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_box_aspect() / get_box_aspect() | 设置Axes盒子纵横比;需在对应对象层级使用;读取Axes盒子纵横比;需在对应对象层级使用 | Axes.set_box_aspect [method] (aspect=None);Axes.get_box_aspect [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.apply_aspect() | 根据当前aspect及adjustable约束应用位置或视图调整 | Axes.apply_aspect [method] (position=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_adjustable() / get_adjustable() | 设置满足纵横比时允许调整的对象;需在对应对象层级使用;读取满足纵横比时允许调整的对象;需在对应对象层级使用 | Axes.set_adjustable [method] (adjustable, share=False);Axes.get_adjustable [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 38
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set_xticks() / get_xticks() | 设置横轴刻度位置;需在对应对象层级使用;读取横轴刻度位置;需在对应对象层级使用 | Axes.set_xticks [method] (ticks, labels=None, *, minor=False, **kwargs);Axes.get_xticks [method] (*, minor=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_yticks() / get_yticks() | 设置纵轴刻度位置;需在对应对象层级使用;读取纵轴刻度位置;需在对应对象层级使用 | Axes.set_yticks [method] (ticks, labels=None, *, minor=False, **kwargs);Axes.get_yticks [method] (*, minor=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_xticklabels() / get_xticklabels() | 设置横轴刻度文字;需在对应对象层级使用;读取横轴刻度文字;需在对应对象层级使用 | Axes.set_xticklabels [method] (labels, *, minor=False, fontdict=None, **kwargs);Axes.get_xticklabels [method] (minor=False, which=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_yticklabels() / get_yticklabels() | 设置纵轴刻度文字;需在对应对象层级使用;读取纵轴刻度文字;需在对应对象层级使用 | Axes.set_yticklabels [method] (labels, *, minor=False, fontdict=None, **kwargs);Axes.get_yticklabels [method] (minor=False, which=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xmajorticklabels() | 取得横轴主刻度Text对象列表 | Axes.get_xmajorticklabels [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xminorticklabels() | 取得横轴次刻度Text对象列表 | Axes.get_xminorticklabels [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_ymajorticklabels() | 取得纵轴主刻度Text对象列表 | Axes.get_ymajorticklabels [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_yminorticklabels() | 取得纵轴次刻度Text对象列表 | Axes.get_yminorticklabels [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xgridlines() | 取得横轴刻度对应网格线Artist | Axes.get_xgridlines [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_ygridlines() | 取得纵轴刻度对应网格线Artist | Axes.get_ygridlines [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xticklines() | 取得横轴刻度线Artist | Axes.get_xticklines [method] (minor=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_yticklines() | 取得纵轴刻度线Artist | Axes.get_yticklines [method] (minor=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.xaxis_date() | 为横轴安装日期单位处理与适当格式 | Axes.xaxis_date [method] (tz=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.yaxis_date() | 为纵轴安装日期单位处理与适当格式 | Axes.yaxis_date [method] (tz=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.minorticks_on() | 为当前尺度安装适用的次刻度定位器 | Axes.minorticks_on [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.minorticks_off() | 关闭次刻度定位 | Axes.minorticks_off [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.ticklabel_format() | 配置ScalarFormatter数值显示,需对应formatter支持 | Axes.ticklabel_format [method] (*, axis='both', style=None, scilimits=None, useOffset=None, useLocale=None, useMathText=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.tick_params() | 设置刻度与标签方向、长度、颜色等属性 | Axes.tick_params [method] (axis='both', **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.locator_params() | 调整刻度定位器的支持参数,不能套任意键 | Axes.locator_params [method] (axis='both', tight=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 39
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.convert_xunits() | 用已注册横轴单位转换器转换输入 | Axes.convert_xunits [method] (x) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.convert_yunits() | 用已注册纵轴单位转换器转换输入 | Axes.convert_yunits [method] (y) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.have_units() | 查询Artist轴上是否具备单位转换条件 | Axes.have_units [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 40
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.add_artist() | 把Artist加入当前容器,坐标变换和范围可能还需设置 | Axes.add_artist [method] (a) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_child_axes() | 把已创建Axes登记为子坐标系 | Axes.add_child_axes [method] (ax) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_collection() | 把Collection加入坐标系,范围更新依选项及对象 | Axes.add_collection [method] (collection, autolim=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_container() | 登记关联Artist容器,不自动重新创建其所有图元 | Axes.add_container [method] (container) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_image() | 把AxesImage加入坐标系 | Axes.add_image [method] (image) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_line() | 把Line2D加入坐标系 | Axes.add_line [method] (line) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_patch() | 把Patch加入坐标系 | Axes.add_patch [method] (p) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_table() | 把Table加入坐标系 | Axes.add_table [method] (tab) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 41
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.twinx() | 共享横轴并建立独立纵轴坐标系 | Axes.twinx [method] (axes_class=None, *, delta_zorder=0.0, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.twiny() | 共享纵轴并建立独立横轴坐标系 | Axes.twiny [method] (axes_class=None, *, delta_zorder=0.0, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.sharex() | 将此Axes横轴加入另一个Axes的共享关系 | Axes.sharex [method] (other) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.sharey() | 将此Axes纵轴加入另一个Axes的共享关系 | Axes.sharey [method] (other) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_shared_x_axes() | 取得横轴共享关系的只读访问视图 | Axes.get_shared_x_axes [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_shared_y_axes() | 取得纵轴共享关系的只读访问视图 | Axes.get_shared_y_axes [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 42
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.get_position() / set_position() | 读取Axes在Figure中的相对位置;需在对应对象层级使用;设置Axes在Figure中的相对位置;需在对应对象层级使用 | Axes.get_position [method] (original=False);Axes.set_position [method] (pos, which='both') | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_anchor() / set_anchor() | 读取Axes布局锚点;需在对应对象层级使用;设置Axes布局锚点;需在对应对象层级使用 | Axes.get_anchor [method] ();Axes.set_anchor [method] (anchor, share=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_axes_locator() / set_axes_locator() | 读取Axes布局定位回调;需在对应对象层级使用;设置Axes布局定位回调;需在对应对象层级使用 | Axes.get_axes_locator [method] ();Axes.set_axes_locator [method] (locator) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_subplotspec() / set_subplotspec() | 读取坐标系对应SubplotSpec;需在对应对象层级使用;设置坐标系对应SubplotSpec;需在对应对象层级使用 | Axes.get_subplotspec [method] ();Axes.set_subplotspec [method] (subplotspec) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.reset_position() | 将Axes活动位置恢复为原始布局位置 | Axes.reset_position [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 43
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.stale | 需重绘的脏状态 | Axes.stale [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.pchanged() | 通知已注册属性变化回调 | Axes.pchanged [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.add_callback() | 注册属性变化观察函数并取得标识 | Axes.add_callback [method] (func) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.remove_callback() | 按标识移除属性变化观察函数 | Axes.remove_callback [method] (oid) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 44
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.can_pan() / can_zoom() | 报告投影是否允许平移;报告投影是否允许缩放 | Axes.can_pan [method] ();Axes.can_zoom [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_navigate() / get_navigate() | 设置工具栏导航许可;需在对应对象层级使用;读取工具栏导航许可;需在对应对象层级使用 | Axes.set_navigate [method] (b);Axes.get_navigate [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.set_navigate_mode() / get_navigate_mode() | 设置当前工具栏导航模式;需在对应对象层级使用;读取当前工具栏导航模式;需在对应对象层级使用 | Axes.set_navigate_mode [method] (b);Axes.get_navigate_mode [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.start_pan() / drag_pan() / end_pan() | 初始化一次平移状态;按鼠标位置和按键修改平移状态;结束平移操作并清理相应临时状态 | Axes.start_pan [method] (x, y, button);Axes.drag_pan [method] (button, key, x, y);Axes.end_pan [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.format_coord() | 构造当前坐标的可读字符串 | Axes.format_coord [method] (x, y) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.format_cursor_data() | 把光标对应数据格式化为文字 | Axes.format_cursor_data [method] (data) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.format_xdata() / format_ydata() | 按横轴formatter将单个值转文字;按纵轴formatter将单个值转文字 | Axes.format_xdata [method] (x);Axes.format_ydata [method] (y) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.mouseover() | 是否参与鼠标悬停数据处理,布尔属性而非命中检测函数 | Axes.mouseover [attribute] 无可调用签名 | 准确属性,无括号;读取/赋值,不是鼠标命中或普通方法 |
| Axes.in_axes() | 判断鼠标事件位置是否位于Axes区域 | Axes.in_axes [method] (mouseevent) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.contains() / contains_point() | 按事件坐标与容差判断是否命中Artist并返回细节;按显示坐标判断点是否位于对象范围 | Axes.contains [method] (mouseevent);Axes.contains_point [method] (point) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_cursor_data() | 取得给定鼠标事件下Artist数据,可能None | Axes.get_cursor_data [method] (event) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_forward_navigation_events() / set_forward_navigation_events() | 读取导航事件转发策略;需在对应对象层级使用;设置导航事件转发策略;需在对应对象层级使用 | Axes.get_forward_navigation_events [method] ();Axes.set_forward_navigation_events [method] (forward) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 45
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.get_children() | 取得容器的直接Artist子对象 | Axes.get_children [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_images() | 取得Axes内图像对象列表 | Axes.get_images [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_lines() | 取得Axes内Line2D列表 | Axes.get_lines [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.findobj() | 遍历Artist树并按条件查找对象 | Axes.findobj [method] (match=None, include_self=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 46
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.draw() | 请求当前图形渲染,属于画布/renderer层而非数据计算 | Axes.draw [method] (renderer) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.draw_artist() | 用当前renderer绘制一个Artist,需画布已具备渲染状态 | Axes.draw_artist [method] (a) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.redraw_in_frame() | 在当前轴框架内重绘已有Artist | Axes.redraw_in_frame [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_window_extent() | 取得显示坐标中的边界框,不一定含所有装饰 | Axes.get_window_extent [method] (renderer=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_tightbbox() | 取得计入相应装饰后的紧边界,变换和renderer需正确 | Axes.get_tightbbox [method] (renderer=None, *, call_axes_locator=True, bbox_extra_artists=None, for_layout_only=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_rasterization_zorder() / set_rasterization_zorder() | 读取低于该层级的图元光栅化阈值;需在对应对象层级使用;设置低于该层级的图元光栅化阈值;需在对应对象层级使用 | Axes.get_rasterization_zorder [method] ();Axes.set_rasterization_zorder [method] (z) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 47
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.name | 投影注册名称 | Axes.name [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xaxis_transform() / get_yaxis_transform() | 取得x数据/y轴比例等混合轴变换;取得y数据/x轴比例等混合轴变换 | Axes.get_xaxis_transform [method] (which='grid');Axes.get_yaxis_transform [method] (which='grid') | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_data_ratio() | 计算当前数据限的纵横比 | Axes.get_data_ratio [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xaxis_text1_transform() | 取得横轴一侧刻度文字变换及对齐 | Axes.get_xaxis_text1_transform [method] (pad_points) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_xaxis_text2_transform() | 取得横轴另一侧刻度文字变换及对齐 | Axes.get_xaxis_text2_transform [method] (pad_points) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_yaxis_text1_transform() | 取得纵轴一侧刻度文字变换及对齐 | Axes.get_yaxis_text1_transform [method] (pad_points) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_yaxis_text2_transform() | 取得纵轴另一侧刻度文字变换及对齐 | Axes.get_yaxis_text2_transform [method] (pad_points) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 48
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Axes.set() | 以关键字批量设置支持的Artist属性 | Axes.set [method] (*, adjustable=<UNSET>, agg_filter=<UNSET>, alpha=<UNSET>, anchor=<UNSET>, animated=<UNSET>, aspect=<UNSET>, autoscale_on=<UNSET>, autoscalex_on=<UNSET>, autoscaley_on=<UNSET>, axes_locator=<UNSET>, axisbelow=<UNSET>, box_aspect=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, facecolor=<UNSET>, forward_navigation_events=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, navigate=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, prop_cycle=<UNSET>, rasterization_zorder=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, subplotspec=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xbound=<UNSET>, xinverted=<UNSET>, xlabel=<UNSET>, xlim=<UNSET>, xmargin=<UNSET>, xscale=<UNSET>, xticklabels=<UNSET>, xticks=<UNSET>, ybound=<UNSET>, yinverted=<UNSET>, ylabel=<UNSET>, ylim=<UNSET>, ymargin=<UNSET>, yscale=<UNSET>, yticklabels=<UNSET>, yticks=<UNSET>, zorder=<UNSET>) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.zorder | Artist堆叠层级 | Axes.zorder [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_figure() | 取得Artist所属Figure或SubFigure,根级选项需按版本 | Axes.get_figure [method] (root=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.figure | 所属Figure或SubFigure | Axes.figure [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.remove() | 从父容器移除Artist,后续重绘和范围更新另控制 | Axes.remove [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.has_data() | 判断坐标系是否含相应数据图元,不证明数据有效 | Axes.has_data [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_default_bbox_extra_artists() | 取得边界计算默认需要考虑的附加Artist | Axes.get_default_bbox_extra_artists [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.get_transformed_clip_path_and_affine() | 把裁剪路径和仿射部分分开返回 | Axes.get_transformed_clip_path_and_affine [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.viewLim | 视图限的Bbox对象 | Axes.viewLim [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.dataLim | 数据限的Bbox对象 | Axes.dataLim [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Axes.spines | 轴外框Spine字典 | Axes.spines [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 49
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.subplots() | 创建画布及规则坐标系网格,返回形状受squeeze影响 | Figure.subplots [method] (nrows=1, ncols=1, *, sharex=False, sharey=False, squeeze=True, width_ratios=None, height_ratios=None, subplot_kw=None, gridspec_kw=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.add_subplot() | 按网格位置建立子图坐标系 | Figure.add_subplot [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.add_axes() | 用相对画布位置建立坐标系 | Figure.add_axes [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.subplot_mosaic() | 按二维标签排列生成命名坐标系,重复标签须形成合法区域 | Figure.subplot_mosaic [method] (mosaic, *, sharex=False, sharey=False, width_ratios=None, height_ratios=None, empty_sentinel='.', subplot_kw=None, per_subplot_kw=None, gridspec_kw=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.add_gridspec() | 建立可控制比例及间距的GridSpec | Figure.add_gridspec [method] (nrows=1, ncols=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.subfigures() | 把父画布分为逻辑子画布 | Figure.subfigures [method] (nrows=1, ncols=1, squeeze=True, wspace=None, hspace=None, width_ratios=None, height_ratios=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.add_subfigure() | 在指定SubplotSpec中加入子画布 | Figure.add_subfigure [method] (subplotspec, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.axes | 容器Axes列表 | Figure.axes [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.get_axes() | 取得画布当前直接坐标系列表 | Figure.get_axes [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.delaxes() | 从画布移除指定坐标系 | Figure.delaxes [method] (ax) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 50
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.savefig() | 保存当前画布或相应对象图形,格式与DPI显式管理 | Figure.savefig [method] (fname, *, transparent=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 51
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.suptitle() / get_suptitle() | 设置Figure或SubFigure的总标题;读取Figure总标题;需在对应对象层级使用 | Figure.suptitle [method] (t, **kwargs);Figure.get_suptitle [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.supxlabel() / get_supxlabel() | 设置Figure或SubFigure共同横轴标签,当前不是pyplot函数;读取Figure共同横轴标签;需在对应对象层级使用 | Figure.supxlabel [method] (t, **kwargs);Figure.get_supxlabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.supylabel() / get_supylabel() | 设置Figure或SubFigure共同纵轴标签,当前不是pyplot函数;读取Figure共同纵轴标签;需在对应对象层级使用 | Figure.supylabel [method] (t, **kwargs);Figure.get_supylabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.colorbar() | 为明确的ScalarMappable添加颜色条 | Figure.colorbar [method] (mappable, cax=None, ax=None, use_gridspec=True, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.legend() | 为带标签图形建立图例,不自动推断业务含义 | Figure.legend [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.text() | 在给定坐标及变换中放置文字 | Figure.text [method] (x, y, s, fontdict=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.align_labels() | 对齐相应子图坐标标签,实际布局需支持 | Figure.align_labels [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.align_xlabels() | 对齐相应子图横轴标签 | Figure.align_xlabels [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.align_ylabels() | 对齐相应子图纵轴标签 | Figure.align_ylabels [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.align_titles() | 对齐相应子图标题 | Figure.align_titles [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.autofmt_xdate() | 旋转日期刻度标签并调整布局相关设置 | Figure.autofmt_xdate [method] (bottom=0.2, rotation=30, ha='right', which='major') | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 52
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.set_size_inches() / get_size_inches() | 设置Figure英寸尺寸;需在对应对象层级使用;读取Figure英寸尺寸;需在对应对象层级使用 | Figure.set_size_inches [method] (w, h=None, forward=True);Figure.get_size_inches [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_figheight() / get_figheight() | 设置Figure英寸高度;需在对应对象层级使用;读取Figure英寸高度;需在对应对象层级使用 | Figure.set_figheight [method] (val, forward=True);Figure.get_figheight [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_figwidth() / get_figwidth() | 设置Figure英寸宽度;需在对应对象层级使用;读取Figure英寸宽度;需在对应对象层级使用 | Figure.set_figwidth [method] (val, forward=True);Figure.get_figwidth [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.dpi | Figure每英寸像素分辨率 | Figure.dpi [attribute] 无可调用签名 | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_dpi() / get_dpi() | 设置每英寸像素分辨率;需在对应对象层级使用;读取每英寸像素分辨率;需在对应对象层级使用 | Figure.set_dpi [method] (val);Figure.get_dpi [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 53
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.subplots_adjust() | 手动设置子图与画布边距及子图间隔 | Figure.subplots_adjust [method] (left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_layout_engine() | 选择或配置Figure布局引擎 | Figure.set_layout_engine [method] (layout=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.get_layout_engine() | 取得当前Figure布局引擎对象 | Figure.get_layout_engine [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.tight_layout() | 基于文字等边界调整布局;优先考虑创建时constrained布局 | Figure.tight_layout [method] (*, pad=1.08, h_pad=None, w_pad=None, rect=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_tight_layout() / get_tight_layout() | 设置历史tight布局设置;需在对应对象层级使用;读取历史tight布局设置;需在对应对象层级使用 | Figure.set_tight_layout [method] (tight);Figure.get_tight_layout [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_constrained_layout() / get_constrained_layout() | 设置历史constrained布局设置;需在对应对象层级使用;读取历史constrained布局设置;需在对应对象层级使用 | Figure.set_constrained_layout [method] (constrained);Figure.get_constrained_layout [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_constrained_layout_pads() / get_constrained_layout_pads() | 设置历史constrained布局留白设置;需在对应对象层级使用;读取历史constrained布局留白设置;需在对应对象层级使用 | Figure.set_constrained_layout_pads [method] (**kwargs);Figure.get_constrained_layout_pads [method] (relative=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 54
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.ginput() | 通过真实GUI交互取得点坐标,Agg无法代替鼠标操作 | Figure.ginput [method] (n=1, timeout=30, show_clicks=True, mouse_add=<MouseButton.LEFT: 1>, mouse_pop=<MouseButton.RIGHT: 3>, mouse_stop=<MouseButton.MIDDLE: 2>) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.waitforbuttonpress() | 等待GUI键盘或鼠标事件,超时与返回值需区分 | Figure.waitforbuttonpress [method] (timeout=-1) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.pick() | 对事件执行Artist拾取遍历,不等于真实用户已操作 | Figure.pick [method] (mouseevent) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.add_axobserver() | 注册Axes增删/切换相关观察回调 | Figure.add_axobserver [method] (func) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 55
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.set_frameon() / get_frameon() | 设置Figure外框显示开关;需在对应对象层级使用;读取Figure外框显示开关;需在对应对象层级使用 | Figure.set_frameon [method] (b);Figure.get_frameon [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_linewidth() / get_linewidth() | 设置外框描边宽度;需在对应对象层级使用;读取外框描边宽度;需在对应对象层级使用 | Figure.set_linewidth [method] (linewidth);Figure.get_linewidth [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_facecolor() / get_facecolor() | 设置容器背景颜色;需在对应对象层级使用;读取容器背景颜色;需在对应对象层级使用 | Figure.set_facecolor [method] (color);Figure.get_facecolor [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_edgecolor() / get_edgecolor() | 设置容器外沿颜色;需在对应对象层级使用;读取容器外沿颜色;需在对应对象层级使用 | Figure.set_edgecolor [method] (color);Figure.get_edgecolor [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 56
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.add_artist() | 把Artist加入当前容器,坐标变换和范围可能还需设置 | Figure.add_artist [method] (artist, clip=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.figimage() | 在画布级放置像素图像,不创建普通Axes图像 | Figure.figimage [method] (X, xo=0, yo=0, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, origin=None, resize=False, *, colorizer=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.get_children() | 取得容器的直接Artist子对象 | Figure.get_children [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 57
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| Figure.clear() | 清空当前容器内容;Figure与Axes的作用范围不同 | Figure.clear [method] (keep_observers=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.gca() | 取得当前坐标系,必要时可能创建,不能当无副作用查询 | Figure.gca [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.sca() | 选择当前坐标系以供后续状态式调用 | Figure.sca [method] (a) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.show() | 请求当前后端展示已管理图形,Agg不产生GUI窗口 | Figure.show [method] (warn=True) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.draw() | 请求当前图形渲染,属于画布/renderer层而非数据计算 | Figure.draw [method] (renderer) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.draw_artist() | 用当前renderer绘制一个Artist,需画布已具备渲染状态 | Figure.draw_artist [method] (a) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.draw_without_rendering() | 在不输出像素情况下计算绘图布局状态 | Figure.draw_without_rendering [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.set_canvas() | 为Figure绑定画布对象 | Figure.set_canvas [method] (canvas) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.get_tightbbox() | 取得计入相应装饰后的紧边界,变换和renderer需正确 | Figure.get_tightbbox [method] (renderer=None, *, bbox_extra_artists=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| Figure.get_window_extent() | 取得显示坐标中的边界框,不一定含所有装饰 | Figure.get_window_extent [method] (renderer=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 58
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| figaspect() | 根据目标宽高比计算适用Figure英寸尺寸 | pyplot.figaspect [method] (arg) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 59
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| SubFigure.subplots() | 创建画布及规则坐标系网格,返回形状受squeeze影响 | SubFigure.subplots [method] (nrows=1, ncols=1, *, sharex=False, sharey=False, squeeze=True, width_ratios=None, height_ratios=None, subplot_kw=None, gridspec_kw=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.add_subplot() | 按网格位置建立子图坐标系 | SubFigure.add_subplot [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.add_axes() | 用相对画布位置建立坐标系 | SubFigure.add_axes [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.subplot_mosaic() | 按二维标签排列生成命名坐标系,重复标签须形成合法区域 | SubFigure.subplot_mosaic [method] (mosaic, *, sharex=False, sharey=False, width_ratios=None, height_ratios=None, empty_sentinel='.', subplot_kw=None, per_subplot_kw=None, gridspec_kw=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.add_gridspec() | 建立可控制比例及间距的GridSpec | SubFigure.add_gridspec [method] (nrows=1, ncols=1, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.subfigures() | 把父画布分为逻辑子画布 | SubFigure.subfigures [method] (nrows=1, ncols=1, squeeze=True, wspace=None, hspace=None, width_ratios=None, height_ratios=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.add_subfigure() | 在指定SubplotSpec中加入子画布 | SubFigure.add_subfigure [method] (subplotspec, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.delaxes() | 从画布移除指定坐标系 | SubFigure.delaxes [method] (ax) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 60
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| SubFigure.suptitle() / get_suptitle() | 设置Figure或SubFigure的总标题;读取Figure总标题;需在对应对象层级使用 | SubFigure.suptitle [method] (t, **kwargs);SubFigure.get_suptitle [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.supxlabel() / get_supxlabel() | 设置Figure或SubFigure共同横轴标签,当前不是pyplot函数;读取Figure共同横轴标签;需在对应对象层级使用 | SubFigure.supxlabel [method] (t, **kwargs);SubFigure.get_supxlabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.supylabel() / get_supylabel() | 设置Figure或SubFigure共同纵轴标签,当前不是pyplot函数;读取Figure共同纵轴标签;需在对应对象层级使用 | SubFigure.supylabel [method] (t, **kwargs);SubFigure.get_supylabel [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.colorbar() | 为明确的ScalarMappable添加颜色条 | SubFigure.colorbar [method] (mappable, cax=None, ax=None, use_gridspec=True, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.legend() | 为带标签图形建立图例,不自动推断业务含义 | SubFigure.legend [method] (*args, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.text() | 在给定坐标及变换中放置文字 | SubFigure.text [method] (x, y, s, fontdict=None, **kwargs) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.align_labels() | 对齐相应子图坐标标签,实际布局需支持 | SubFigure.align_labels [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.align_xlabels() / align_ylabels() | 对齐相应子图横轴标签;对齐相应子图纵轴标签 | SubFigure.align_xlabels [method] (axs=None);SubFigure.align_ylabels [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.align_titles() | 对齐相应子图标题 | SubFigure.align_titles [method] (axs=None) | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 61
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| SubFigure.add_artist() | 把Artist加入当前容器,坐标变换和范围可能还需设置 | SubFigure.add_artist [method] (artist, clip=False) | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.get_children() | 取得容器的直接Artist子对象 | SubFigure.get_children [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.set_frameon() / get_frameon() | 设置Figure外框显示开关;需在对应对象层级使用;读取Figure外框显示开关;需在对应对象层级使用 | SubFigure.set_frameon [method] (b);SubFigure.get_frameon [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.set_linewidth() / get_linewidth() | 设置外框描边宽度;需在对应对象层级使用;读取外框描边宽度;需在对应对象层级使用 | SubFigure.set_linewidth [method] (linewidth);SubFigure.get_linewidth [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.set_facecolor() / get_facecolor() | 设置容器背景颜色;需在对应对象层级使用;读取容器背景颜色;需在对应对象层级使用 | SubFigure.set_facecolor [method] (color);SubFigure.get_facecolor [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.set_edgecolor() / get_edgecolor() | 设置容器外沿颜色;需在对应对象层级使用;读取容器外沿颜色;需在对应对象层级使用 | SubFigure.set_edgecolor [method] (color);SubFigure.get_edgecolor [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
| SubFigure.set_dpi() / get_dpi() | 设置每英寸像素分辨率;需在对应对象层级使用;读取每英寸像素分辨率;需在对应对象层级使用 | SubFigure.set_dpi [method] (val);SubFigure.get_dpi [method] () | 存在性和签名记录,不代表所有参数组合实际运行 |
当前接口与配置分组 62
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| default | 默认中性样式 | style | 独立用途说明,不自动验收所有行为 |
| ggplot | 灰底与网格风格 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8 | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-bright | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-colorblind | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-dark | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-dark-palette | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-darkgrid | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-deep | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-muted | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-notebook | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-paper | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-pastel | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-poster | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-talk | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-ticks | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-white | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| seaborn-v0_8-whitegrid | Matplotlib内置Seaborn0.8系列静态样式;不等于当前Seaborn包全部主题能力 | style | 独立用途说明,不自动验收所有行为 |
| fivethirtyeight | 数据报道风格 | style | 独立用途说明,不自动验收所有行为 |
| dark_background | 深色底色风格,需核对文字对比 | style | 独立用途说明,不自动验收所有行为 |
| bmh | 统计计算展示风格 | style | 独立用途说明,不自动验收所有行为 |
| grayscale | 灰度输出,仍需线型区别系列 | style | 独立用途说明,不自动验收所有行为 |
| classic | 早期Matplotlib外观兼容样式 | style | 独立用途说明,不自动验收所有行为 |
| fast | 简化渲染配置,速度依图元和后端 | style | 独立用途说明,不自动验收所有行为 |
| Solarize_Light2 | 浅色Solarized风格 | style | 独立用途说明,不自动验收所有行为 |
| tableau-colorblind10 | 面向分类的调色配置,仍需实际可辨识检查 | style | 独立用途说明,不自动验收所有行为 |
当前接口与配置分组 63
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| figure.figsize | 默认画布宽高,单位英寸 | [6.4, 4.8] | 本轮实际配置值,不宣称各版本都相同 |
| figure.dpi | 默认像素分辨率,像素约为英寸乘DPI | 100.0 | 本轮实际配置值,不宣称各版本都相同 |
| figure.facecolor | 画布底色 | 'white' | 本轮实际配置值,不宣称各版本都相同 |
| figure.edgecolor | 画布边沿色 | 'white' | 本轮实际配置值,不宣称各版本都相同 |
| font.size | 默认文字字号,单位pt | 10.0 | 本轮实际配置值,不宣称各版本都相同 |
| font.family | 字体族选择,实际字体须存在 | ['sans-serif'] | 本轮实际配置值,不宣称各版本都相同 |
| font.sans-serif | 无衬线字体候选,列表不能保证中文覆盖 | ['DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif'] | 本轮实际配置值,不宣称各版本都相同 |
| axes.titlesize | 坐标系标题字号 | 'large' | 本轮实际配置值,不宣称各版本都相同 |
| axes.labelsize | 轴标签字号 | 'medium' | 本轮实际配置值,不宣称各版本都相同 |
| axes.grid | 默认主网格开关 | False | 本轮实际配置值,不宣称各版本都相同 |
| axes.facecolor | 坐标系底色 | 'white' | 本轮实际配置值,不宣称各版本都相同 |
| axes.spines.top | 顶部轴框显示 | True | 本轮实际配置值,不宣称各版本都相同 |
| axes.spines.right | 右侧轴框显示 | True | 本轮实际配置值,不宣称各版本都相同 |
| lines.linewidth | 线的默认宽度,单位pt | 1.5 | 本轮实际配置值,不宣称各版本都相同 |
| lines.markersize | Line2D标记默认尺寸,scatter默认面积会取平方 | 6.0 | 本轮实际配置值,不宣称各版本都相同 |
| lines.linestyle | 默认连线形式 | '-' | 本轮实际配置值,不宣称各版本都相同 |
| legend.loc | 图例默认位置策略 | 'best' | 本轮实际配置值,不宣称各版本都相同 |
| legend.fontsize | 图例文字字号 | 'medium' | 本轮实际配置值,不宣称各版本都相同 |
| xtick.labelsize | 横轴刻度文字字号 | 'medium' | 本轮实际配置值,不宣称各版本都相同 |
| ytick.labelsize | 纵轴刻度文字字号 | 'medium' | 本轮实际配置值,不宣称各版本都相同 |
| savefig.dpi | 保存DPI或沿用figure设置 | 'figure' | 本轮实际配置值,不宣称各版本都相同 |
| savefig.bbox | 保存边界策略,tight可能改变像素尺寸 | None | 本轮实际配置值,不宣称各版本都相同 |
| image.cmap | 标量图像默认色图 | 'viridis' | 本轮实际配置值,不宣称各版本都相同 |
| image.interpolation | 图像重采样方式,当前默认auto不是旧antialiased | 'auto' | 本轮实际配置值,不宣称各版本都相同 |
当前接口与配置分组 64
| 技术条目 | 独立用途 | 当前签名/值/类型 | 条件与迁移 |
|---|---|---|---|
| 感知均匀(Sequential) | 连续量的顺序色图;按数据及视觉条件选择 | viridis, plasma, inferno, magma, cividis | 当前注册检查;_r反转映射,数据条件仍需解释 |
| 顺序(单色渐变) | 从低到高的顺序变化 | Greys, Purples, Blues, Greens, Oranges, Reds, YlOrBr, YlOrRd, OrRd, PuRd, RdPu, BuPu, GnBu, PuBu, YlGnBu, PuBuGn, BuGn, YlGn | 当前注册检查;_r反转映射,数据条件仍需解释 |
| 发散(Diverging) | 有明确中心或参考点的双向变化 | PiYG, PRGn, BrBG, PuOr, RdGy, RdBu, RdYlBu, RdYlGn, Spectral, coolwarm, bwr, seismic | 当前注册检查;_r反转映射,数据条件仍需解释 |
| 循环(Cyclic) | 角度等周期变量,首尾连续性重要 | twilight, twilight_shifted, hsv | 当前注册检查;_r反转映射,数据条件仍需解释 |
| 定性(Qualitative) | 离散分类,不能当数值间距 | Pastel1, Pastel2, Paired, Accent, Dark2, Set1, Set2, Set3, tab10, tab20, tab20b, tab20c | 当前注册检查;_r反转映射,数据条件仍需解释 |
| 杂项 | 特殊或历史色图,需检查感知失真与业务意义 | flag, prism, ocean, gist_earth, terrain, gist_stern, gnuplot, gnuplot2, CMRmap, cubehelix, brg, gist_rainbow, rainbow, jet, turbo, nipy_spectral, gist_ncar | 当前注册检查;_r反转映射,数据条件仍需解释 |
本章独立核心源码与验证步骤
from plot_lab import run
if __name__ == "__main__":
run('matplotlib-func')
所需环境:Matplotlib3.11.2/NumPy2.5.4/Pandas3.1.0/Seaborn0.13.2/Pillow13.0.0;Python3.12 Windows Agg
当前源码 SHA256:7b187cb175f5520ecb700375289e920a71cac6662f70dd94e580620abc50c048
- 当前章全部明确断言通过;实际值、环境及文件哈希写入observations.json
- PNG可实际打开且属于本章,原图缺失与本站结果分开
本章真实实现和分支
"""Independent, deterministic Matplotlib experiments for mbsky.com."""
from pathlib import Path
import argparse,json,sys,hashlib,warnings,inspect
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
from matplotlib.ft2font import FT2Font
import numpy as np
from PIL import Image
MARKERS=['.',',','o','v','^','<','>','1','2','3','4','8','s','p','P','*','h','H','+','x','X','D','d','|','_',*range(12),'None',' ','','$f$']
COLORS={'b':(0,0,1,1),'g':(0,.5,0,1),'r':(1,0,0,1),'c':(0,.75,.75,1),'m':(.75,0,.75,1),'y':(.75,.75,0,1),'k':(0,0,0,1),'w':(1,1,1,1)}
def chinese_font(path=None):
# A fallback font may advertise every codepoint but render generic boxes.
# Never select Last Resort by a simple character-map membership search.
if path:
p=Path(path).resolve();assert p.is_file()
else:
p=Path(fm.findfont(fm.FontProperties(family='Microsoft YaHei'),fallback_to_default=False))
face=FT2Font(str(p));assert 'last resort'not in face.family_name.lower()
assert all(ord(c)in face.get_charmap()for c in '蓝色天空网学习中文负号')
return fm.FontProperties(fname=str(p)),dict(path=str(p),family=face.family_name,sha256=hashlib.sha256(p.read_bytes()).hexdigest(),redistributed=False)
def rgb_float(a):
a=np.asarray(a)
if np.issubdtype(a.dtype,np.integer):
assert a.min()>=0
a=a.astype(float)/np.iinfo(a.dtype).max
else:a=a.astype(float,copy=True)
if not np.isfinite(a).all() or a.min()<0 or a.max()>1:raise ValueError('RGB values must be finite in0..1')
return a
def run(key):
parser=argparse.ArgumentParser();parser.add_argument('--output',default='generated-'+key);parser.add_argument('--font');arg=parser.parse_args()
out=Path(arg.output).resolve();out.mkdir(parents=True,exist_ok=True);records=[];images=[];rng=np.random.default_rng(20261103)
def check(name,condition,actual):
if not condition:raise AssertionError((name,actual))
records.append(dict(case=name,passed=True,actual=actual))
def save(fig,name):
fig.suptitle('MBSKY | mbsky.com — '+name,fontsize=12)
target=out/(name+'.png');fig.canvas.draw();fig.savefig(target,dpi=120)
with Image.open(target)as im:
assert im.format=='PNG'and im.width>100 and im.height>100
arr=np.asarray(im.convert('RGB'));assert arr.std()>3
size=list(im.size)
images.append(dict(file=target.name,sha256=hashlib.sha256(target.read_bytes()).hexdigest(),size=size));plt.close(fig)
def error(name,action,expected=ValueError):
try:action()
except expected as e:check(name,True,type(e).__name__)
else:raise AssertionError('Expected error: '+name)
with matplotlib.rc_context({'figure.figsize':(8,5),'figure.dpi':120,'axes.grid':False}):
if key in {'matplotlib-tutorial','matplotlib-install'}:
f,a=plt.subplots(layout='constrained');line,=a.plot([1,2,3,4],[4,7,6,10],marker='o',label='Practice');a.set(xlabel='Round',ylabel='Simulated exercises');a.legend();check('actual_version_and_backend',matplotlib.__version__=='3.11.2'and matplotlib.get_backend().lower()=='agg',dict(matplotlib=matplotlib.__version__,numpy=np.__version__,python=sys.version,backend=matplotlib.get_backend(),requires_python=__import__('importlib.metadata',fromlist=['metadata']).metadata('matplotlib').get('Requires-Python')));check('coordinates',list(line.get_ydata())==[4,7,6,10],[int(v)for v in line.get_ydata()]);save(f,'first-learning-chart')
elif key=='matplotlib-pyplot':
f,axes=plt.subplots(2,3,layout='constrained')
inputs=[([0,6],[0,100],'-'),([1,8],[3,10],'-'),([1,8],[3,10],'o'),([1,2,6,8],[3,8,1,10],'-')]
for ax,(x,y,fmt)in zip(axes.flat,inputs):
line,=ax.plot(x,y,fmt);check('explicit-'+fmt+'-'+str(len(records)),np.array_equal(line.get_xdata(),x),dict(x=x,y=y,linestyle=line.get_linestyle()));ax.set_title('Explicit x/y '+fmt)
for ax,y in zip(list(axes.flat)[4:],[[3,10],[3,8,1,10,5,7]]):
line,=ax.plot(y,'r+');check('implicit-x-'+str(len(y)),list(line.get_xdata())==list(range(len(y))),[float(v)for v in line.get_xdata()]);ax.set_title('Implicit x: 0..N-1')
save(f,'plot-coordinate-branches');f,a=plt.subplots(layout='constrained');x=np.arange(0,4*np.pi,.1);lines=a.plot(x,np.sin(x),x,np.cos(x));lines[0].set_label('sin(x)');lines[1].set_label('cos(x)');a.legend();check('sin_cos_two_series',len(lines)==2 and np.allclose(lines[1].get_ydata(),np.cos(x)),dict(points=len(x),series=2));save(f,'sin-cos');f,a=plt.subplots();l,=a.plot([2,5,3],'bo');check('blue_circle_format',l.get_color()=='b'and l.get_marker()=='o',dict(color=l.get_color(),marker=l.get_marker()));save(f,'blue-circle-format')
elif key=='matplotlib-marker':
f,axes=plt.subplots(9,5,figsize=(12,16),layout='constrained')
for ax,m in zip(axes.flat,MARKERS):
line,=ax.plot([0,1,2],[0,1,0],marker=m);ax.set_title(repr(m));check('marker-'+repr(m),line.get_marker()==m,repr(line.get_marker()))
for ax in list(axes.flat)[len(MARKERS):]:ax.set_visible(False)
save(f,'all-marker-values');f,axes=plt.subplots(1,4,figsize=(12,4),layout='constrained')
styles=[dict(ms=20),dict(ms=20,mec='red'),dict(ms=20,mfc='red'),dict(ms=20,mec='#4CAF50',mfc='#4CAF50')]
for ax,style in zip(axes,styles):
l,=ax.plot([1,3,2],marker='o',**style);check('marker-style-'+str(len(records)),l.get_markersize()==20,dict(size=l.get_markersize(),edge=str(l.get_markeredgecolor()),face=str(l.get_markerfacecolor())))
save(f,'marker-size-face-edge');f,a=plt.subplots();l,=a.plot([2,6,3],'o:r');check('format-string',l.get_marker()=='o'and l.get_linestyle()==':'and l.get_color()=='r',dict(marker=l.get_marker(),line=l.get_linestyle(),color=l.get_color()));save(f,'format-string')
elif key=='matplotlib-line':
f,axes=plt.subplots(2,4,figsize=(12,7),layout='constrained');styles=['solid','dotted','dashed','dashdot','None','',' ']
for a,s in zip(axes.flat,styles):
l,=a.plot([4,1,5,3],linestyle=s,marker='o');a.set_title(repr(s));check('linestyle-'+repr(s),l.get_linestyle()in{'-',':','--','-.','None'},l.get_linestyle())
axes.flat[-1].set_visible(False);save(f,'line-styles');f,axes=plt.subplots(2,2,layout='constrained')
for a,color in zip(axes.flat,['r','#8FBC8F','SeaGreen','b']):
l,=a.plot([2,5,3],c=color,lw=12.5);check('color-width-'+color,l.get_linewidth()==12.5,dict(color=l.get_color(),linewidth=l.get_linewidth()))
save(f,'line-color-width');f,a=plt.subplots();lines=a.plot([0,1,2],[1,4,2],[0,1,2,3],[3,1,5,2]);check('different_length_series',len(lines)==2 and len(lines[1].get_xdata())==4,[len(l.get_xdata())for l in lines]);save(f,'multiple-lines');f,axes=plt.subplots(2,4,figsize=(12,6),layout='constrained')
for a,color in zip(axes.flat,COLORS):
l,=a.plot([1,3,2],color=color);a.set_title(color);a.set_facecolor('#dddddd');check('short-color-'+color,matplotlib.colors.to_rgba(l.get_color())==COLORS[color],COLORS[color])
save(f,'all-short-line-colors')
elif key in {'matplotlib-label','matplotlib-zh'}:
prop,font=chinese_font(arg.font);f,axes=plt.subplots(1,3,figsize=(13,4),layout='constrained')
for a,loc,yloc in zip(axes,['left','center','right'],['bottom','center','top']):
a.plot([-2,-1,0,1,2],[-4,-2,0,2,4],label='学习量');a.set_title('蓝色天空网',fontproperties=prop,loc=loc,color='blue',size=16);a.set_xlabel('学习轮次',fontproperties=prop,loc=loc);a.set_ylabel('模拟练习量',fontproperties=prop,loc=yloc);a.legend(prop=prop)
with warnings.catch_warnings(record=True)as ws:
warnings.simplefilter('always');f.canvas.draw();missing=[str(w.message)for w in ws if 'Glyph'in str(w.message)]
check('actual_chinese_font_no_missing_glyphs',not missing,dict(font=font,missing=missing));save(f,'chinese-label-locations')
f,axes=plt.subplots(1,2,layout='constrained');x=np.linspace(-3,3,20)
for a,minus in zip(axes,[True,False]):
with matplotlib.rc_context({'axes.unicode_minus':minus,'font.family':font['family']}):
a.scatter(x,np.sin(x)+rng.normal(0,.2,len(x)),label='模拟观测');a.plot(x,np.sin(x),label='设定规律');a.legend(prop=prop);a.set_title('Unicode minus='+str(minus));f.canvas.draw();labels=[t.get_text()for t in a.get_xticklabels()];check('minus-'+str(minus),any(('−'if minus else '-')in t for t in labels),labels)
save(f,'noise-and-negative-ticks')
elif key=='matplotlib-grid':
f,axes=plt.subplots(2,2,layout='constrained')
for a in axes.flat:a.plot([1,2,3,4],[1,4,9,16]);a.set_xticks([1,2,3,4]);a.set_yticks([0,5,10,15])
axes[0,0].grid(True);axes[0,1].grid(True,axis='x');axes[1,0].grid(color='r',ls='--',lw=.5);axes[1,1].minorticks_on();axes[1,1].grid(True,which='both');f.canvas.draw()
x=axes[0,1].get_xgridlines();y=axes[0,1].get_ygridlines();check('x_grid_only',all(l.get_visible()for l in x)and not any(l.get_visible()for l in y),dict(x_visible=sum(l.get_visible()for l in x),y_visible=sum(l.get_visible()for l in y)));check('grid_width',all(l.get_linewidth()==.5 for l in axes[1,0].get_xgridlines()),.5);axes[0,0].grid(False);check('explicit_off',not any(l.get_visible()for l in axes[0,0].get_xgridlines()),False);axes[0,0].grid(True);save(f,'grid-branches')
elif key=='matplotlib-subplots':
f=plt.figure(layout='constrained')
for index in range(1,5):
a=f.add_subplot(2,2,index);a.plot([1,2,3],[index,2*index,index]);a.set_title('subplot index='+str(index));check('subplot-index-'+str(index),a.get_subplotspec().num1==index-1,a.get_subplotspec().num1)
save(f,'subplot-index');
for shape in [(1,1),(1,2),(2,1),(2,2)]:
f,axes=plt.subplots(*shape,squeeze=False);check('squeeze-false-'+str(shape),axes.shape==shape,list(axes.shape));plt.close(f)
for shape,expected in [((1,1),()),((1,2),(2,)),((2,1),(2,)),((2,2),(2,2))]:
f,axes=plt.subplots(*shape);check('squeeze-default-'+str(shape),np.shape(axes)==expected,list(np.shape(axes)));plt.close(f)
for share in ['none','all','row','col',True,False]:
f,axes=plt.subplots(2,2,sharex=share,sharey=share);j=axes[0,0].get_shared_x_axes();same_row=j.joined(axes[0,0],axes[0,1]);same_col=j.joined(axes[0,0],axes[1,0]);check('share-'+str(share),(same_row,same_col)==((True,True)if share in{'all',True}else(True,False)if share=='row'else(False,True)if share=='col'else(False,False)),dict(row=same_row,col=same_col));plt.close(f)
f,axes=plt.subplots(2,2,subplot_kw={'projection':'polar'},layout='constrained');x=np.linspace(0,2*np.pi,100)
for a in axes.flat:a.plot(x,1+.3*np.sin(3*x))
check('polar_axes',all(a.name=='polar'for a in axes.flat),[a.name for a in axes.flat]);save(f,'polar-subplots');f,a=plt.subplots(num=10);a.plot([1,2]);f,b=plt.subplots(num=10,clear=True);check('clear_reused_figure',len(f.axes)==1 and not b.lines,len(f.axes));plt.close(f)
elif key=='matplotlib-scatter':
f,axes=plt.subplots(2,3,figsize=(12,7),layout='constrained');x=np.arange(8);y=np.array([1,4,9,16,7,11,23,18]);sizes=np.array([20,50,100,200,500,1000,60,90]);c=axes[0,0].scatter(x,y);check('default_area',np.allclose(c.get_sizes(),[matplotlib.rcParams['lines.markersize']**2]),c.get_sizes().tolist());c=axes[0,1].scatter(x,y,s=sizes);check('per_point_area',np.array_equal(c.get_sizes(),sizes),c.get_sizes().tolist());axes[0,2].scatter(x,y,c=['red','green','black','orange','purple','beige','cyan','magenta']);axes[1,0].scatter(x,y,color='hotpink');axes[1,0].scatter(x[:5],y[:5]+2,color='#88c999')
for a,cmap in zip(axes[1,1:],['viridis','afmhot_r']):
c=a.scatter(x,y,s=sizes,c=np.linspace(0,100,8),cmap=cmap,alpha=.5);f.colorbar(c,ax=a);check('cmap-'+cmap,c.get_cmap().name==cmap and c.get_alpha()==.5,c.get_clim())
save(f,'scatter-size-color');f,a=plt.subplots();c=a.scatter(rng.random(50),rng.random(50),s=(30*rng.random(50))**2,c=rng.random(50),alpha=.5);check('random_points',c.get_offsets().shape==(50,2),list(c.get_offsets().shape));save(f,'scatter-seeded')
f,a=plt.subplots();error('normalize_vmin_conflict',lambda:a.scatter([1,2],[1,2],c=[1,2],norm=matplotlib.colors.Normalize(0,3),vmin=0));plt.close(f)
elif key=='matplotlib-bar':
f,axes=plt.subplots(2,3,figsize=(12,7),layout='constrained');names=['A','B','C','D'];values=[12,22,6,18]
for a,mode in zip(axes.flat,['vertical','horizontal','single-color','colors','thin-width','thin-height']):
if mode in{'horizontal','thin-height'}:bars=a.barh(names,values,height=.1 if mode=='thin-height'else .8);check(mode,[b.get_width()for b in bars]==values,[b.get_width()for b in bars])
else:bars=a.bar(names,values,width=.1 if mode=='thin-width'else .8,color=['#4CAF50','red','hotpink','#556B2F']if mode=='colors'else'#4CAF50');check(mode,[b.get_height()for b in bars]==values,[b.get_height()for b in bars])
a.set_title(mode)
save(f,'bar-orientation-width');f,a=plt.subplots();bars=a.bar([1,2],[4,6],width=-.4,align='edge',bottom=[1,2]);check('negative_width_right_edge',np.allclose([max(b.get_x(),b.get_x()+b.get_width())for b in bars],[1,2]),[max(b.get_x(),b.get_x()+b.get_width())for b in bars]);save(f,'bar-right-edge')
elif key=='matplotlib-pie':
f,axes=plt.subplots(2,2,figsize=(10,9),layout='constrained');values=[35,25,25,15]
for a,name,kw in zip(axes.flat,['plain','labels-colors','explode-one-decimal','two-decimal-clockwise'],[{},dict(labels=list('ABCD'),colors=['#d5695d','#5d8ca8','#65a479','#a564c9']),dict(labels=list('ABCD'),explode=[0,.1,0,0],autopct='%.1f%%',shadow=True,startangle=90),dict(labels=list('ABCD'),explode=[0,.2,0,0],autopct='%.2f%%',counterclock=False)]):
result=a.pie(values,**kw);check('pie-container-'+name,type(result).__name__=='PieContainer',dict(type=type(result).__name__,unpacked=len(tuple(result)),wedges=len(result.wedges)));angles=[abs(w.theta2-w.theta1)for w in result.wedges];check('pie-angles-'+name,np.allclose(angles,[126,90,90,54],atol=1e-4),angles);a.set_title(name)
save(f,'pie-branches');f,a=plt.subplots();p=a.pie([.2,.3],normalize=False);check('partial_pie',np.isclose(sum(w.theta2-w.theta1 for w in p.wedges),180,atol=1e-4),sum(w.theta2-w.theta1 for w in p.wedges));error('sum_over_one_without_normalization',lambda:a.pie([2,3],normalize=False));error('negative_pie',lambda:a.pie([2,-1]));save(f,'partial-pie');f,a=plt.subplots();p=a.pie([15,30,45,10],labels=list('ABCD'),radius=1.2,center=(.2,.1),frame=True,rotatelabels=True,autopct='%.1f%%',pctdistance=.5,labeldistance=.9,wedgeprops={'linewidth':2,'edgecolor':'black'},textprops={'fontsize':10});check('pie_geometry_and_text',all(np.isclose(w.r,1.2)and w.get_linewidth()==2 for w in p.wedges),dict(center=p.wedges[0].center,radius=p.wedges[0].r,return_length=len(tuple(p))));save(f,'pie-position-and-properties')
elif key=='matplotlib-hist':
import pandas as pd
f,axes=plt.subplots(2,3,figsize=(12,7),layout='constrained');data=np.array([0,.5,1,1.5,2,3,4]);edges=[0,1,2,4];n,b,_=axes[0,0].hist(data,bins=edges);check('bin_edges_last_inclusive',n.tolist()==[2,2,3],n.tolist());n,b,_=axes[0,1].hist(data,bins=edges,density=True);area=float(np.sum(n*np.diff(b)));check('density_area_not_sum',np.isclose(area,1)and not np.isclose(n.sum(),1),dict(area=area,height_sum=float(n.sum())));n,_,_=axes[0,2].hist(data,bins=edges,weights=np.arange(1,8));check('weighted_total',n.sum()==28,n.tolist());n,_,_=axes[1,0].hist(data,bins=edges,cumulative=True);check('cumulative_total',n[-1]==7,n.tolist());groups=[rng.normal(m,1,1000)for m in[0,2,-2]];axes[1,1].hist(groups,bins=np.linspace(-6,6,31),alpha=.5,label=['mean0','mean2','mean-2']);axes[1,1].legend();pd.DataFrame({'practice':rng.normal(170,10,250)}).hist(ax=axes[1,2]);save(f,'histogram-branches');f,a=plt.subplots();a.hist(pd.Series(rng.normal(size=100)),bins=10,histtype='step',orientation='horizontal');check('series_count',len(a.patches)==1,len(a.patches));save(f,'series-horizontal-step');f,a=plt.subplots();n,b,patches=a.hist([[0,1,2],[1,2,3]],bins=[0,1,2,3],stacked=True,label=['GroupA','GroupB']);a.legend();check('stacked_total',np.allclose(n[-1],[1,2,3]),n.tolist());save(f,'hist-stacked')
elif key in {'matplotlib-imshow','matplotlib-imsave','matplotlib-imread'}:
error('imsave_norm_not_supported',lambda:plt.imsave(out/'unsupported-norm.png',np.zeros((2,2)),norm=matplotlib.colors.Normalize()),TypeError);gray=np.linspace(0,1,100).reshape(10,10);rgb=np.stack([gray,np.flipud(gray),np.full_like(gray,.3)],axis=-1);rgba=np.dstack([rgb,np.full_like(gray,.7)]);plt.imsave(out/'mbsky-gray.png',gray,cmap='gray');plt.imsave(out/'mbsky-rgb.png',rgb);plt.imsave(out/'mbsky-rgb.jpg',rgb);Image.fromarray((gray*255).astype('uint8')).save(out/'mbsky-l-gray.png');plt.imsave(out/'mbsky-rgba.png',rgba)
decoded={n:plt.imread(out/n)for n in['mbsky-gray.png','mbsky-rgb.png','mbsky-rgb.jpg','mbsky-l-gray.png','mbsky-rgba.png']};check('gray_2d',decoded['mbsky-l-gray.png'].shape==(10,10),dict(shape=list(decoded['mbsky-l-gray.png'].shape),dtype=str(decoded['mbsky-l-gray.png'].dtype)));check('cmap_gray_saved_rgba',decoded['mbsky-gray.png'].shape==(10,10,4),list(decoded['mbsky-gray.png'].shape));check('jpeg_uint8',decoded['mbsky-rgb.jpg'].dtype==np.uint8,dict(dtype=str(decoded['mbsky-rgb.jpg'].dtype),shape=list(decoded['mbsky-rgb.jpg'].shape)));check('png_float',np.issubdtype(decoded['mbsky-rgb.png'].dtype,np.floating),str(decoded['mbsky-rgb.png'].dtype));check('dtype_normalization',np.allclose(rgb_float(np.array([0,255],dtype=np.uint8)),[0,1]),[0,1]);error('invalid_float_rgb',lambda:rgb_float(np.array([0.,255.])))
f,axes=plt.subplots(2,3,figsize=(12,7),layout='constrained');matrix=np.linspace(0,1,16).reshape(4,4)
for a,name,arr,kw in zip(axes.flat,['gray','RGB','hot','matrix','nearest','bicubic'],[gray,rgb,gray,gray,matrix,matrix],[dict(cmap='gray'),{},dict(cmap='hot',origin='lower',extent=[-2,2,-1,1]),{},dict(interpolation='nearest'),dict(interpolation='bicubic')]):
im=a.imshow(arr,**kw);a.set_title(name);check('image-shape-'+name,np.array_equal(im.get_array(),arr),dict(shape=list(im.get_array().shape),origin=im.origin,extent=[float(x)for x in im.get_extent()]));
if name=='hot':f.colorbar(im,ax=a)
save(f,'imshow-branches');f,a=plt.subplots();Y,X=np.mgrid[:80,:120];plan=np.zeros((80,120,3),dtype=float);plan[:]=[.9,.95,1];plan[20:60,30:90]=[.3,.65,.4];plan[:,58:64]=[.3,.6,.95];plan[38:43,:]=[.3,.6,.95];plt.imsave(out/'mbsky-simulated-plan.png',plan);opened=Image.open(out/'mbsky-simulated-plan.png');a.imshow(np.asarray(opened));a.set_axis_off();check('local_owned_plan_dependency',opened.size==(120,80),dict(size=list(opened.size),kind='Owned simulated plan, not original map or measured geography'));save(f,'owned-simulated-plan');source=rgb_float(decoded['mbsky-rgb.jpg']);f,axes=plt.subplots(2,2,layout='constrained')
for a,factor in zip(axes.flat,[1,.8,.6,.4]):a.imshow(source*factor);a.set_title('RGB scale '+str(factor));a.set_axis_off()
check('darkening_preserves_alpha',np.allclose(np.dstack([rgba[:,:,:3]*.4,rgba[:,:,3]])[:,:,3],rgba[:,:,3]),.7);save(f,'image-darkening');f,axes=plt.subplots(1,2,layout='constrained');crop=source[1:8,2:7,:];red=source.copy();red[:,:,[1,2]]=0;axes[0].imshow(crop);axes[1].imshow(red);check('crop_shape',crop.shape==(7,5,3),list(crop.shape));check('red_channels_zero',np.all(red[:,:,1:]==0)and np.any(source[:,:,1:]>0),True);save(f,'crop-and-red');
if key=='matplotlib-imsave':
f,axes=plt.subplots(1,3,figsize=(12,4),layout='constrained')
for a,name in zip(axes,['mbsky-gray.png','mbsky-rgb.png','mbsky-rgb.jpg']):
a.imshow(decoded[name]);a.set_title(name+' / '+str(decoded[name].dtype));a.set_axis_off()
save(f,'saved-arrays-and-formats')
for file in out.glob('mbsky-*'):
with Image.open(file)as im:check('saved-format-'+file.name,im.format==('JPEG'if file.suffix=='.jpg'else'PNG'),dict(format=im.format,mode=im.mode,size=list(im.size)))
elif key=='seaborn-tutorial':
import seaborn as sns,pandas as pd
df=pd.DataFrame({'group':np.repeat(['A','B','C'],20),'round':np.tile(np.arange(20),3),'value':np.concatenate([rng.normal(m,1,20)for m in[3,6,4]])});f,axes=plt.subplots(2,3,figsize=(12,8),layout='constrained')
with sns.axes_style('whitegrid'),sns.plotting_context('notebook'):
sns.scatterplot(data=df,x='round',y='value',hue='group',ax=axes[0,0]);sns.lineplot(data=df,x='round',y='value',errorbar=None,ax=axes[0,1]);sns.barplot(data=df,x='group',y='value',errorbar=None,ax=axes[0,2]);sns.boxplot(data=df,x='group',y='value',ax=axes[1,0]);sns.heatmap(pd.DataFrame({'A':[1,2,3,4,5],'B':[5,4,3,2,1]}).corr(),annot=True,fmt='.2f',cmap='coolwarm',ax=axes[1,1]);sns.violinplot(data=df,x='group',y='value',ax=axes[1,2])
expected=df.groupby('group')['value'].mean().to_numpy();actual=np.array([p.get_height()for p in axes[0,2].patches]);check('barplot_category_means',np.allclose(actual,expected),actual.tolist());check('correlation_minus_one',np.isclose(pd.Series([1,2,3,4,5]).corr(pd.Series([5,4,3,2,1])),-1),-1);save(f,'seaborn-six-functions')
for style in ['darkgrid','whitegrid','dark','white','ticks']:check('style-'+style,bool(sns.axes_style(style)),dict(sns.axes_style(style)))
for context in ['paper','notebook','talk','poster']:check('context-'+context,sns.plotting_context(context)['font.size']>0,sns.plotting_context(context)['font.size'])
elif key in {'matplotlib-func','matplotlib-apiref'}:
catalog=json.loads((Path(__file__).parent/'api-catalog.json').read_text(encoding='utf8'));missing={(t['owner'],t['name'])for r in catalog['records']for t in r.get('targets',[])if not t['exists']};check('catalog_owner_corrections',missing=={('pyplot','supxlabel'),('pyplot','supylabel')},sorted(missing));check('catalog_all_rows',len(catalog['records'])==1009,len(catalog['records']))
x=np.linspace(0,10,100);f,a=plt.subplots(layout='constrained');a.plot(x,np.sin(x),label='sin');a.plot(x,np.cos(x),'--',label='cos');index=int(np.argmax(np.sin(x)));a.scatter([x[index]],[np.sin(x[index])],s=100);a.annotate('Sampled peak',xy=(x[index],np.sin(x[index])),xytext=(4,1.2),arrowprops={'arrowstyle':'->'});a.legend();check('sampled_peak',np.sin(x[index])==max(np.sin(x)),dict(index=index,x=float(x[index]),y=float(np.sin(x[index]))));save(f,'reference-lines-peak')
f,axes=plt.subplots(2,2,layout='constrained');axes[0,0].plot(x,np.sin(x));axes[0,1].scatter(rng.random(50),rng.random(50));bars=axes[1,0].bar(['A','B','C'],[23,45,56]);axes[1,0].bar_label(bars);axes[1,1].hist(rng.normal(size=1000),bins=30);check('reference_four_panels',len(f.axes)==4,len(f.axes));save(f,'reference-four-panels')
f,axes=plt.subplots(1,2,layout='constrained');q=np.linspace(-3,3,100);X,Y=np.meshgrid(q,q);Z=np.sin(X)*np.cos(Y);im=axes[0].imshow(Z,extent=[-3,3,-3,3],origin='lower');cs=axes[1].contourf(X,Y,Z,levels=15);axes[1].contour(X,Y,Z,levels=15,colors='black',linewidths=.5);f.colorbar(im,ax=axes[0]);f.colorbar(cs,ax=axes[1]);check('reference_field',Z.shape==(100,100),list(Z.shape));save(f,'reference-heatmap-contours')
with plt.style.context('ggplot'):
f,a=plt.subplots(layout='constrained');a.plot(x,np.exp(-x/3)*np.sin(2*x),'o-',label='Damped sin');a.plot(x,np.exp(-x/3)*np.cos(2*x),'s--',label='Damped cos');a.legend();path=out/'mbsky-damped-300dpi.png';f.savefig(path,dpi=300);check('actual_300dpi_output',Image.open(path).size==(2400,1500),list(Image.open(path).size));save(f,'reference-damped-style')
f,axes=plt.subplot_mosaic([['A','A','A'],['B','C','D']],layout='constrained');axes['A'].plot(x,np.sin(x));axes['B'].pie([3,2,1]);axes['C'].bar(['X','Y','Z'],[10,25,15]);axes['D'].imshow(rng.random((5,5)));check('mosaic_four_named_axes',set(axes)==set('ABCD'),list(axes));save(f,'reference-mosaic')
f,a=plt.subplots(layout='constrained');a.plot(x,np.sin(x));twin=a.twinx();twin.plot(x,np.exp(x/5),'r--');ins=a.inset_axes([.15,.5,.3,.35]);ins.plot(x,np.sin(x));ins.set(xlim=(3,5),ylim=(-1.2,1.2));a.indicate_inset_zoom(ins);secondary=a.secondary_xaxis('top',functions=(lambda v:v*180/np.pi,lambda v:v*np.pi/180));check('twin_shared_x',a.get_shared_x_axes().joined(a,twin),True);check('secondary_inverse',np.allclose((x*180/np.pi)*np.pi/180,x),True);save(f,'reference-dual-inset-secondary')
else:raise ValueError(key)
result=dict(chapter=key,passed=True,records=records,images=images,backend=matplotlib.get_backend(),source_scripts_executed=False,scope='Own deterministic numerical/Artist/Agg file execution; not GUI, Notebook, source-semantic or user acceptance')
(out/'observations.json').write_text(json.dumps(result,ensure_ascii=False,indent=2,default=lambda v:v.item()if isinstance(v,np.generic)else str(v))+'\n',encoding='utf8');print(json.dumps(result,ensure_ascii=False,default=lambda v:v.item()if isinstance(v,np.generic)else str(v)))
所需环境:Matplotlib3.11.2/NumPy2.5.4/Pandas3.1.0/Seaborn0.13.2/Pillow13.0.0;Python3.12 Windows Agg
当前源码 SHA256:7159c5c25ec5426843135cca762df7f51a6a4c64744dacbd9decca9c67649c34
- 当前章全部明确断言通过;实际值、环境及文件哈希写入observations.json
- PNG可实际打开且属于本章,原图缺失与本站结果分开
常见错误与边界
- 把属性当方法,或把旧参数/默认值套到当前版本。
- 把Agg静态图当桌面/Notebook交互验收,或把本站复现图当原图。
练习与解答
在副本改变一个数据、格式或有效条件,先预判再运行核对。
展开参考解答
按数组形状、数值/几何、文字和图元状态分别对照,勿仅检查PNG数量。