Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Lmplot | Regression Models
Deep Dive into the seaborn Visualization

book
Lmplot

Note

lmplot = FacetGrid + regplot

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Task

Swipe to start coding

  1. Set the 'darkgrid' style with the 'lightpink' figure.facecolor.
  2. Create a lmplot using the seaborn library:
  • Set the x parameter equals the 'total_bill';
  • Set the y parameter equals the 'tip';
  • Set the hue parameter equals 'smoker';
  • Set the col parameter equals the 'sex';
  • Set the 'o' and 'x' markers;
  • Set the 'crest' palette;
  • Set the data;
  • Display the plot.

Solution

# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/tips.csv')

# Set the 'darkgrid' style with the 'lightpink' figure facecolor
sns.set_style('darkgrid', {'figure.facecolor' : 'lightpink'})
# Create a lmplot
sns.lmplot(# Set the x
x = 'total_bill',
# Set the y
y = 'tip',
# Set the hue
hue = 'smoker',
# Set the col
col = 'sex',
# Set the markers
markers = ['o', 'x'],
# Set the palette
palette = 'crest',
# Set the data
data = df)

# Display the plot
plt.show()

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 6. Chapter 2
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/tips.csv')

# Set the 'darkgrid' style with the 'lightpink' figure facecolor
___('___', {'figure.___' : '___'})
# Create a lmplot
___(# Set the x
___,
# Set the y
___,
# Set the hue
___,
# Set the col
___,
# Set the markers
___,
# Set the palette
___ = 'crest',
# Set the data
___ = df)

# Display the plot
___

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

We use cookies to make your experience better!
some-alt