Visualizing the Lmplots
Learn how to plot, design, and interpret lmplots for data visualizations.
We'll cover the following...
Overview
Lmplot stands for the linear model plot. We use it to visualize the trends between variables. The reg plot and lmplot are closely related. However, the former is an axes-level function while the latter is a figure-level function that combines a reg plot and a FacetGrid
property. The FacetGrid
property allows us to plot multiple plots in parallel.
Plotting and styling
We’ve already imported the mpg
dataset and stored the DataFrame in a variable named mpg_df
(after removing the null records). We can draw a lmplot using the sns.lmplot()
function and pass the displacement
and horsepower
variables.
Press + to interact
sns.lmplot(x= 'displacement', y ='horsepower', data = mpg_df )plt.savefig('output/graph.png')
The plot looks exactly like a reg plot. We can see an upward trend; as the ...