Search⌘ K
AI Features

Joint Plots

Learn how to create joint plots using Seaborn to visualize the relationship between two variables along with their distributions. Discover different plot types like scatter, KDE, regression, and histograms, and explore customization options for styling and enhancing your visualizations effectively.

We'll cover the following...

Overview

A joint plot allows us to see the relationship between two variables and the distribution of the variables together. It combines bivariate and univariate graphs in a single plot.

Plotting joint plots

To get started, we import the required libraries and storing the mpg dataset in the DataFrame mpg_df (after removing the null values). Let’s draw a joint plot for the horsepower and mpg variables using the sns.jointplot() function. A joint plot plots a relational plot as the main plot and a distribution plot along the axis.

Python
sns.jointplot( x= 'horsepower', y= 'mpg', data = mpg_df)
plt.savefig('output/graph.png')

We can observe from the plot above that as the horsepower increases, we see a decrease in mpg. This results in a negative correlation between mpg and horsepower. Similarly, on the x-axis, we see the horsepower marginal distribution represented in histograms. We see that most cars have a horsepower between 50–100. Similarly, on the y-axis, we see that most cars have an mpg ...