- Seaborn Tutorial
- Seaborn - Home
- Seaborn - Introduction
- Seaborn - Environment Setup
- Importing Datasets and Libraries
- Seaborn - Figure Aesthetic
- Seaborn- Color Palette
- Seaborn - Histogram
- Seaborn - Kernel Density Estimates
- Visualizing Pairwise Relationship
- Seaborn - Plotting Categorical Data
- Distribution of Observations
- Seaborn - Statistical Estimation
- Seaborn - Plotting Wide Form Data
- Multi Panel Categorical Plots
- Seaborn - Linear Relationships
- Seaborn - Facet Grid
- Seaborn - Pair Grid
- Function Reference
- Seaborn - Function Reference
- Seaborn Useful Resources
- Seaborn - Quick Guide
- Seaborn - Useful Resources
- Seaborn - Discussion
Seaborn Regression plots - Introduction
A statistical charting tool called Seaborn offers straightforward techniques for adding regression lines to your scatter diagrams and can read Pandas dataframes as well as other types of data formats. An excellent tool for examining links or trends in data is a scatter plot. But by including a regression line, those patterns can become more obvious.
In an effort to discover the scatter plot's points that fit together the best, the regression line is used.
Drawing regression plots with small data. We begin by importing the seaborn library
import seaborn as sns
We can draw a scatterplot for any dataset by using the below code snippet. Considering the following case, we are using the in-built titanic dataset in seaborn library and x,y parameters are passed to the scatterplot() method and a graph is obtained.
sns.scatterplot(data=titanic,x="age",y="fare")
The output is obtained as follows −
On observing the above plot, you will be able to understand the linear relationship but drawing a regression line makes it easier.
The above figure shows the regression line drawn over the plot.
Since we have understood how regression lines help us, now we will see how to add regression lines to your plots. This can be done with the help of the regression plot methods in seaborn.
There are three different types of regression plots in seaborn.
S.No | Method & Description |
---|---|
1 |
seaborn.regplot() method is used to plot data and draw a linear regression model fit. |
2 |
seaborn.lmplot() method is used to plot data and draw regression model fits across grids where multiple plots can be plotted. |
3 |
seaborn.residplot() method is used to plot residual data of a linear regression. |
To Continue Learning Please Login
Login with Google