Histplot
The distributions module contains several functions designed to answer questions such as these. The axes-level functions are histplot
, kdeplot
, ecdfplot
, and rugplot
. They are grouped together within the figure-level displot
function.
A histplot
is a classic visualization tool that represents the distribution of one or more variables by counting the number of observations that fall within discrete bins.
Click the slider to view possible arguments for the plot!
















Don't forget to return back after exploring the dataset!
Note
Use
plt.show()
to display the plot.
Taak
Swipe to start coding
- Create the histplot using the
seaborn
library:
- Set the
x
parameter equals the'bill_length_mm'
; - Set the
hue
parameter equals the'island'
; - Set the
element
parameter equals the'step'
; - Set the
stat
parameter equals the'density'
; - Set the
binwidth
parameter equals1
; - Set the
'flare'
palette; - Use the
df
data for the plot; - Display the plot.
Oplossing
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
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/penguins.csv')
# Create a histplot
sns.histplot(# Set the x
x = 'bill_length_mm',
# Set the hue
hue = 'island',
# Set the element
element = 'step',
# Set the stat
stat = 'density',
# Set the binwidth
binwidth = 1,
# Set the palette
palette = 'flare',
# Set the data
data = df)
# Display the plot
plt.show()
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 1
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
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/penguins.csv')
# Create a histplot
sns.___(# Set the x
x = '___',
# Set the hue
hue = '___',
# Set the element
element = '___',
# Set the stat
stat = '___',
# Set the binwidth
___ = 1,
# Set the palette
___ = '___',
# Set the data
data = ___)
# Display the plot
___
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.