Set axes labels and axes limits
In this particular example, we will be changing the label and the limit of the plot in a single code with the help of the suitable required functions of the python library.
Python3
# import packages import matplotlib.pyplot as plt import seaborn as sns # create data data = [ 3 , 7 , 9 , 11 , 12 , 14 , 15 , 16 , 18 , 19 , 20 , 23 , 25 , 28 ] # plot distplot fig, ax = plt.subplots() sns.distplot(data, ax = ax) # This will change the limits of the x-axis ax.set_xlim( 1 , 70 ) # This will add label to the X-axis ax.set_xlabel( "GFG X" ) # This will add label to the Y-axis ax.set_ylabel( "GFG Y" ) # This will add title to the plot ax.set_title( "GFG - GFG" ) plt.show() |
Output:
How to set axes labels & limits in a Seaborn plot?
In this article, we will learn How to set axes labels & limits in a Seaborn plot. Let’s discuss some concepts first.
- Axis is the region in the plot that contains the data space. The Axes contain two or three-axis(in case of 3D) objects which take care of the data limits.
- Axes Labels are the labels that describe the axes’ values in terms of meaning, units, and direction.
- Axes Limits are the limits to the axes’ values, which are used to filter for a required value on axes.
Here, In this article, the content goes from setting the axes labels, axes limits, and both at a time. In the end, you will be able to learn how to set axes labels & limits in a Seaborn plot.