Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. There are two methods available in the Axes module to change the limits:
- matplotlib.axes.Axes.set_xlim(): Axes module of matplotlib library is used to set the x-axis view limits.
- matplotlib.axes.Axes.set_ylim(): Axes module of matplotlib library is used to set the y-axis view limits.
Syntax:
Axes.set_xlim(self, left=None, right=None, emit=True, auto=False, *, xmin=None, xmax=None)
Axes.set_ylim(self, bottom=None, top=None, emit=True, auto=False, *, ymin=None, ymax=None)
Parameters:
- bottom: This parameter is the bottom xlim/ylim in data coordinates
- top: This parameter is the top xlim/ylim in data coordinates
- emit: This parameter is used to notify observers of limit change.
- auto: This parameter is used to turn on autoscaling of the x-axis/y-axis.
- xmin,xmax,ymin, ymax: These parametersthe are equivalent to bottom and top and it is an error to pass both xmin/ymin and bottom or xmax/ymax and top.
Returns:-
  bottom, top: This returns the new x-axis/y-axis limits in data coordinates.
Example 1:
Python3
# Import moduleimport matplotlib.pyplot as pltimport seaborn as snsÂ
# assign datadata = [3, 7, 9, 11, 12, 14,        15, 16, 18, 19, 20,        23, 25, 28]Â
# depict visualizationfig, ax = plt.subplots()sns.distplot(data, ax=ax)ax.set_xlim(1, 70)plt.show() |
Output:
Example 2:
Python3
# import moduleimport seaborn as snssns.set_style("whitegrid")Â
# assign datasettips = sns.load_dataset("tips")Â
# depict visualizationgfg = sns.boxplot(x="day", y="total_bill",                  data=tips)gfg.set_ylim(0, 80) |
Output:

