VOOZH about

URL: https://www.geeksforgeeks.org/python/visualizing-relationship-between-variables-with-scatter-plots-in-seaborn/

⇱ Visualizing Relationship between variables with scatter plots in Seaborn - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Visualizing Relationship between variables with scatter plots in Seaborn

Last Updated : 15 Jul, 2025

To understand how variables in a dataset are related to one another and how that relationship is dependent on other variables, we perform statistical analysis. This Statistical analysis helps to visualize the trends and identify various patterns in the dataset. One of the functions which can be used to get the relationship between two variables in Seaborn is relplot().

Relplot() combines FacetGrid with either of the two axes-level functions scatterplot() and lineplot(). Scatterplot is default kind of relplot(). Using this we can visualize joint distribution of two variables through a cloud of points. We can draw scatterplot in seaborn using various ways. The most common one is when both the variables are numeric.

Example: Let's take an example of a dataset that consists a data of CO2 emissions of different vehicles. To get the dataset click here. Let's plot the basic scatterplot for visualizing the relation between the target variable "CO2EMISSIOnS" and "ENGINE SIZE" Output: 👁 Image
We can add visualize one more variable by adding another dimension to the plot. This can be done by using "hue", which colors the points of the third variable, thus adding a meaning to it. Output: 👁 Image
To highlight the different classes, we can add marker styles Output: 👁 Image
In the previous example, hue semantic was for a categorical variable, so it had a default qualitative palette. But if we use a numerical variable instead of categorical, then the default palette used is sequential, which can be modified too. Output: 👁 Image
We can also change the size of points for the third variable.
Output: 👁 Image
Comment
Article Tags: