Rugplot
The rugplot
is intended to complement other plots by showing the location of individual observations in an unobtrusive way.






Task
Swipe to start coding
- Set the
'darkgrid'
style with the disabled'axes.grid'
and the'axes.facecolor'
equals the'aliceblue'
(color). We learned how to do that in the first part of the course. - Create the
kdeplot
using theseaborn
library. - Create the
rugplot
using theseaborn
library:
- Set the
x
parameter equals the'total_bill'
; - Set the
hue
parameter equals the'sex'
; - Set the
height
parameter equals0.05
; - Set the
'magma'
palette
; - Set the data using the
df
; - 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
29
30
31
32
33
34
35
36
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# 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
sns.set_style('darkgrid',
# Disable the axes.grid
{'axes.grid' : False,
# Set the 'aliceblue' facecolor
'axes.facecolor' : 'aliceblue'})
# Create a kdeplot
sns.kdeplot(x = 'total_bill',
hue = 'sex',
palette = 'magma',
multiple = 'layer',
fill = True,
data = df)
# Create a rugplot
sns.rugplot(# Set the x
x = 'total_bill',
# Set the hue
hue = 'sex',
# Set the height
height = 0.05,
# Set the palette
palette = 'magma',
Everything was clear?
Thanks for your feedback!
Section 2. Chapter 3
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
29
30
31
32
33
34
35
36
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# 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
sns.set_style('___',
# Disable the axes.grid
{'axes.___ ' : ___,
# Set the 'aliceblue' facecolor
'___.facecolor' : '___'})
# Create a kdeplot
sns.___(x = 'total_bill',
hue = 'sex',
palette = 'magma',
multiple = 'layer',
fill = True,
data = df)
# Create a rugplot
sns.___(# Set the x
___,
# Set the hue
___,
# Set the height
height = ___,
# Set the palette
___,
Ask AI
Ask anything or try one of the suggested questions to begin our chat