Swarmplot
The swarmplot
is similar to stripplot
. Only the points are adjusted so they won't overlap, as it helps to represent the distribution of values better.











Завдання
Swipe to start coding
- Set the
'whitegrid'
style with the'seashell'
axes.facecolor
. - Create the
swarmplot
using theseaborn
library:
x
parameter equals the'day'
;- Set the
y
parameter equals the'total_bill'
; - Set the
hue
parameter equals the'sex'
; - Set the
linewidth
parameter equals1
; - Set the
size
parameter equals2
; - Set the
dodge
parameter equals theTrue
; - Set the
'rocket'
palette.
Рішення
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
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 'seashell' facecolor
sns.set_style('whitegrid', {'axes.facecolor': 'seashell'})
# Create a swarmplot
sns.swarmplot(# Set the x
x = 'day',
# Set the y
y = 'total_bill',
# Set the hue
hue = 'sex',
# Set the linewidth
linewidth = 1,
# Set the size
size = 2,
# Set the dodge
dodge = True,
# Set the palette
palette = 'rocket',
# Setting the data
data = df)
# Displaying the plot
plt.show()
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 3. Розділ 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
29
30
31
32
33
34
35
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 'seashell' facecolor
___('___', {___})
# Create a swarmplot
___(# Set the x
___,
# Set the y
___,
# Set the hue
___,
# Set the linewidth
___,
# Set the size
___ = 2,
# Set the dodge
dodge = ___,
# Set the palette
palette = '___',
# Setting the data
data = df)
# Displaying the plot
plt.show()
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат