-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage079.py
More file actions
32 lines (27 loc) · 919 Bytes
/
Copy pathpage079.py
File metadata and controls
32 lines (27 loc) · 919 Bytes
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
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
# 未设置样式
fig, ax = plt.subplots()
ax = sns.violinplot(x = 'time', y = 'total_bill',
hue = 'sex', data = tips,
split = True)
plt.show()
# 设置样式之后
sns.set_style('whitegrid')
fig, ax = plt.subplots()
ax = sns.violinplot(x = 'time', y = 'total_bill',
hue = 'sex', data = tips,
split = True)
plt.show()
fig = plt.figure()
seaborn_styles = ['darkgrid', 'whitegrid', 'dark', 'white', 'ticks']
for idx, style in enumerate(seaborn_styles):
plot_position = idx + 1
with sns.axes_style(style):
ax = fig.add_subplot(2, 3, plot_position)
violin = sns.violinplot(x = 'time', y = 'total_bill',data = tips,
ax = ax)
violin.set_title(style)
fig.tight_layout()
plt.show()