Lmplot
Note
lmplot
=FacetGrid
+regplot












Task
Swipe to start coding
- Set the
'darkgrid'
style with the'lightpink'
figure.facecolor
. - Create a
lmplot
using theseaborn
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
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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?
Thanks for your feedback!
Section 6. Chapter 2
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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
Ask anything or try one of the suggested questions to begin our chat