matplotlib.axes.Axes.set_ylim#

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

Set the y-axis view limits.

Parameters:
bottomfloat, optional

The bottom ylim in data coordinates. PassingNone leaves thelimit unchanged.

The bottom and top ylims may also be passed as the tuple(bottom,top) as the first positional argument (or asthebottom keyword argument).

topfloat, optional

The top ylim in data coordinates. PassingNone leaves thelimit unchanged.

emitbool, default: True

Whether to notify observers of limit change.

autobool or None, default: False

Whether to turn on autoscaling of the y-axis.True turns on,False turns off,None leaves unchanged.

ymin, ymaxfloat, optional

They are equivalent to bottom and top respectively, and it is anerror to pass bothymin andbottom orymax andtop.

Returns:
bottom, top(float, float)

The new y-axis limits in data coordinates.

Notes

Thebottom value may be greater than thetop value, in whichcase the y-axis values will decrease frombottom totop.

Examples

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

One limit may be left unchanged.

>>>set_ylim(top=top_lim)

Limits may be passed in reverse order to flip the direction ofthe y-axis. For example, supposey represents depth of theocean in m. The y-axis limits might be set like the followingso 5000 m depth is at the bottom of the plot and the surface,0 m, is at the top.

>>>set_ylim(5000,0)

Examples usingmatplotlib.axes.Axes.set_ylim#

Decay

Decay

Animated histogram

Animated histogram

Rain simulation

Rain simulation

Matplotlib unchained

Matplotlib unchained

Inset locator demo 2

Inset locator demo 2

Parasite Simple2

Parasite Simple2

Simple Axisline

Simple Axisline

Data browser

Data browser

Path editor

Path editor

Pick event demo 2

Pick event demo 2

Polygon editor

Polygon editor

Zoom modifies other Axes

Zoom modifies other Axes

Contouring the solution space of optimizations

Contouring the solution space of optimizations

Image resampling

Image resampling

Image nonuniform

Image nonuniform

pcolormesh grids and shading

pcolormesh grids and shading

Streamplot

Streamplot

Grouped bar chart with labels

Grouped bar chart with labels

EventCollection Demo

EventCollection Demo

Hat graph

Hat graph

Markevery Demo

Markevery Demo

Multicolored lines

Multicolored lines

Power spectral density (PSD)

Power spectral density (PSD)

Custom projection

Custom projection

Apply SVG filter to a line

Apply SVG filter to a line

TickedStroke patheffect

TickedStroke patheffect

Plot 2D data on 3D plot

Plot 2D data on 3D plot

Draw flat objects in 3D plot

Draw flat objects in 3D plot

Text annotations in 3D

Text annotations in 3D

Asinh scale

Asinh scale

Loglog aspect

Loglog aspect

Mmh Donuts!!!

Mmh Donuts!!!

Hatchcolor Demo

Hatchcolor Demo

Plot multiple lines using a LineCollection

Plot multiple lines using a LineCollection

Anatomy of a figure

Anatomy of a figure

Integral as the area under a curve

Integral as the area under a curve

XKCD

XKCD

Ishikawa Diagram

Ishikawa Diagram

SkewT-logP diagram: using transforms and custom projections

SkewT-logP diagram: using transforms and custom projections

Boxplots

Boxplots

Align labels and titles

Align labels and titles

Axes Demo

Axes Demo

Broken axis

Broken axis

Annotate transform

Annotate transform

Annotating a plot

Annotating a plot

AnnotationBbox demo

AnnotationBbox demo

Using a text as a Path

Using a text as a Path

Annotation with units

Annotation with units

Artist tests

Artist tests

Annotated cursor

Annotated cursor

Cursor

Cursor

Span Selector

Span Selector

Path Tutorial

Path Tutorial

Transformations Tutorial

Transformations Tutorial

Axis ticks

Axis ticks

Placing colorbars

Placing colorbars

Constrained layout guide

Constrained layout guide

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Specifying colors

Specifying colors

Quick start guide

Quick start guide

Annotations

Annotations