matplotlib.axes.Axes.set_ylim#

Axes.set_ylim(bottom=None, top=None, *, emit=True, auto=False, ymin=None, ymax=None)[源代码]#

设置 y 轴视图限制。

参数:
底部浮点数,可选

数据坐标中的底部 y 轴限制。传递 None 将保持限制不变。

底部和顶部的 y 轴限制也可以作为元组 (bottom, top) 传递作为第一个位置参数(或作为 bottom 关键字参数)。

顶部浮点数,可选

数据坐标中的顶部 y 轴限制。传递 None 将保持限制不变。

发出bool, 默认值: True

是否通知观察者限制更改。

自动布尔值或无, 默认: False

是否开启 y 轴的自动缩放。True 开启,False 关闭,None 保持不变。

ymin, ymax浮点数,可选

它们分别等同于底部和顶部,同时传递 yminbottomymaxtop 是错误的。

返回:
底部, 顶部(浮点数, 浮点数)

数据坐标中的新 y 轴限制。

注释

如果 bottom 值大于 top 值,则 y 轴的值将从 bottom 递减到 top

示例

>>> set_ylim(bottom, top)
>>> set_ylim((bottom, top))
>>> bottom, top = set_ylim(bottom, top)

可以保留一个限制不变。

>>> set_ylim(top=top_lim)

可以以相反的顺序传递限制来翻转 y 轴的方向。例如,假设 y 表示海洋的深度(单位:米)。y 轴的限制可以设置如下,使得 5000 米深度位于图的底部,而表面 0 米位于顶部。

>>> set_ylim(5000, 0)

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

带标签的分组条形图

Grouped bar chart with labels

断开的条形图

Broken Barh

事件集合演示

EventCollection Demo

帽子图

Hat graph

Markevery 演示

Markevery Demo

多色线条

Multicolored lines

功率谱密度 (PSD)

Power spectral density (PSD)

优化解决方案空间的轮廓

Contouring the solution space of optimizations

图像重采样

Image resampling

图像非均匀

Image nonuniform

pcolormesh 网格和阴影

pcolormesh grids and shading

坐标轴演示

Axes Demo

断开的轴

Broken axis

箱线图

Boxplots

对齐 y 轴标签

Align y-labels

注释变换

Annotate transform

注释图表

Annotating a plot

AnnotationBbox 演示

AnnotationBbox demo

将文本用作路径

Using a text as a Path

带有自动缩放的线、多边形和正多边形集合

Line, Poly and RegularPoly Collection with autoscaling

Mmh 甜甜圈!!!

Mmh Donuts!!!

使用 LineCollection 绘制多条线

Plot multiple lines using a LineCollection

插入定位器演示 2

Inset locator demo 2

寄生虫 Simple2

Parasite Simple2

简单轴垫

Simple axis pad

简单轴线

Simple Axisline

图的结构

Anatomy of a figure

积分作为曲线下的面积

Integral as the area under a curve

XKCD

XKCD

衰变

Decay

动画直方图

Animated histogram

雨模拟

Rain simulation

Matplotlib 解禁

Matplotlib unchained

数据浏览器

Data browser

路径编辑器

Path editor

选择事件演示 2

Pick event demo 2

多边形编辑器

Polygon editor

Zoom 修改其他 Axes

Zoom modifies other Axes

自定义投影

Custom projection

将 SVG 滤镜应用于一行

Apply SVG filter to a line

TickedStroke 路径效果

TickedStroke patheffect

在3D图上绘制2D数据

Plot 2D data on 3D plot

在3D图中绘制平面物体

Draw flat objects in 3D plot

3D 文本注释

Text annotations in 3D

Asinh 演示

Asinh Demo

对数对数比例

Loglog aspect

日志演示

Log Demo

石川图

Ishikawa Diagram

SkewT-logP 图:使用变换和自定义投影

SkewT-logP diagram: using transforms and custom projections

带有单位的注释

Annotation with units

艺术家测试

Artist tests

带注释的光标

Annotated cursor

光标

Cursor

Span Selector

Span Selector

快速入门指南

Quick start guide

路径教程

Path Tutorial

变换教程

Transformations Tutorial

轴刻度

Axis ticks

放置颜色条

Placing colorbars

指定颜色

Specifying colors

在 Matplotlib 中选择颜色表

Choosing Colormaps in Matplotlib

注解

Annotations