matplotlib.axes.Axes.axis#

Axes.axis(arg=None,/,*,emit=True,**kwargs)[source]#

Convenience method to get or set some axis properties.

Call signatures:

xmin,xmax,ymin,ymax=axis()xmin,xmax,ymin,ymax=axis([xmin,xmax,ymin,ymax])xmin,xmax,ymin,ymax=axis(option)xmin,xmax,ymin,ymax=axis(**kwargs)
Parameters:
xmin, xmax, ymin, ymaxfloat, optional

The axis limits to be set. This can also be achieved using

ax.set(xlim=(xmin,xmax),ylim=(ymin,ymax))
optionbool or str

If a bool, turns axis lines and labels on or off. If a string,possible values are:

Value

Description

'off' orFalse

Hide all axis decorations, i.e. axis labels, spines,tick marks, tick labels, and grid lines.This is the same asset_axis_off().

'on' orTrue

Do not hide all axis decorations, i.e. axis labels, spines,tick marks, tick labels, and grid lines.This is the same asset_axis_on().

'equal'

Set equal scaling (i.e., make circles circular) bychanging the axis limits. This is the same asax.set_aspect('equal',adjustable='datalim').Explicit data limits may not be respected in this case.

'scaled'

Set equal scaling (i.e., make circles circular) bychanging dimensions of the plot box. This is the same asax.set_aspect('equal',adjustable='box',anchor='C').Additionally, further autoscaling will be disabled.

'tight'

Set limits just large enough to show all data, thendisable further autoscaling.

'auto'

Automatic scaling (fill plot box with data).

'image'

'scaled' with axis limits equal to data limits.

'square'

Square plot; similar to 'scaled', but initially forcingxmax-xmin==ymax-ymin.

emitbool, default: True

Whether observers are notified of the axis limit change.This option is passed on toset_xlim andset_ylim.

Returns:
xmin, xmax, ymin, ymaxfloat

The axis limits.

Notes

For 3D Axes, this method additionally takeszmin,zmax asparameters and likewise returns them.

Examples usingmatplotlib.axes.Axes.axis#

Parasite Simple2

Parasite Simple2

Simple Axisline4

Simple Axisline4

Axis Direction

Axis Direction

axis_direction demo

axis_direction demo

Axis line styles

Axis line styles

floating_axes features

floating_axes features

Parasite Axes demo

Parasite Axes demo

Parasite axis demo

Parasite axis demo

Ticklabel alignment

Ticklabel alignment

Ticklabel direction

Ticklabel direction

Simple axis direction

Simple axis direction

Simple axis tick label and tick directions

Simple axis tick label and tick directions

Simple axis pad

Simple axis pad

Custom spines with axisartist

Custom spines with axisartist

Simple Axisline

Simple Axisline

Simple Axisline3

Simple Axisline3

Colors in the default property cycle

Colors in the default property cycle

Clipping images with patches

Clipping images with patches

Streamplot

Streamplot

Filled polygon

Filled polygon

Packed-bubble chart

Packed-bubble chart

TickedStroke patheffect

TickedStroke patheffect

Bar of pie

Bar of pie

Hatch style reference

Hatch style reference

PathPatch object

PathPatch object

Ishikawa Diagram

Ishikawa Diagram

ggplot style sheet

ggplot style sheet

Specifying colors

Specifying colors

Quick start guide

Quick start guide

Text in Matplotlib

Text in Matplotlib