Stripplot
In statistics, a categorical variable is a variable that can take on one of a limited and usually fixed number of possible values, assigning each individual or other unit of observation to a particular group or nominal category on the basis of some qualitative property.
A stripplot
is a single-axis scatter plot that is used to visualize the distribution of many individual one-dimensional values. The values are plotted as dots along one unique axis, and the dots with the same value can overlap.











Opgave
Swipe to start coding
- Set the
'whitegrid'
style with the'aliceblue'
axes.facecolor
. - Create the
stripplot
using theseaborn
library:
- Set the
x
parameter equals the'day'
; - Set the
y
parameter equals the'total_bill'
; - Set the
hue
parameter equals the'smoker'
; - Set the
size
parameter equals20
; - Set the
'crest'
palette; - Set the
'D'
marker; - Set the
alpha
parameter equals0.25
.
Løsning
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 'whitegrid' style with the 'aliceblue' facecolor
sns.set_style('whitegrid', {'axes.facecolor': 'aliceblue'})
# Create a stripplot
sns.stripplot(# Set the x
x = 'day',
# Set the y
y = 'total_bill',
# Set the hue
hue = 'smoker',
# Set the size
size = 20,
# Set the palette
palette = 'crest',
# Set the marker
marker = 'D',
# Set the alpha
alpha = 0.25,
# Setting the data
data = df)
# Displaying the plot
plt.show()
# Importing libraries needed
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 'whitegrid' style with the 'aliceblue' facecolor
sns.set_style('whitegrid', {'axes.facecolor': 'aliceblue'})
# Create a stripplot
sns.stripplot(# Set the x
x = 'day',
# Set the y
y = 'total_bill',
# Set the hue
hue = 'smoker',
# Set the size
size = 20,
# Set the palette
palette = 'crest',
# Set the marker
marker = 'D',
# Set the alpha
alpha = 0.25,
# Setting the data
data = df)
# Displaying the plot
plt.show()
# 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 'whitegrid' style with the 'aliceblue' facecolor
___('___', {'axes.___': ___})
# Create a stripplot
___(# Set the x
___,
# Set the y
___,
# Set the hue
hue = '___',
# Set the size
___ = 20,
# Set the palette
palette = '___',
# Set the marker
___,
# Set the alpha
___ = 0.25,
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat