matplotlib.pyplot.xlim#

matplotlib.pyplot.xlim(*args,**kwargs)[source]#

Get or set the x limits of the current Axes.

Call signatures:

left,right=xlim()# return the current xlimxlim((left,right))# set the xlim to left, rightxlim(left,right)# set the xlim to left, right

If you do not specify args, you can passleft orright as kwargs,i.e.:

xlim(right=3)# adjust the right leaving left unchangedxlim(left=1)# adjust the left leaving right unchanged

Setting limits turns autoscaling off for the x-axis.

Returns:
left, right

A tuple of the new x-axis limits.

Notes

Calling this function with no arguments (e.g.xlim()) is the pyplotequivalent of callingget_xlim on the current Axes.Calling this function with arguments is the pyplot equivalent of callingset_xlim on the current Axes. All arguments are passed though.

Examples usingmatplotlib.pyplot.xlim#

Frame grabbing

Frame grabbing

Interactive functions

Interactive functions

Shared axis

Shared axis