-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage075.py
More file actions
34 lines (27 loc) · 853 Bytes
/
Copy pathpage075.py
File metadata and controls
34 lines (27 loc) · 853 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
33
34
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
tips = sns.load_dataset("tips")
fig, ax = plt.subplots()
ax = tips['total_bill'].plot.hist()
plt.show()
# 为DataFrame绘制直方图
# 设置alpha通道透明度,使重叠的部分透明可见
fig, ax = plt.subplots()
ax = tips[['total_bill', 'tip']].plot.hist(alpha = 0.5, bins = 20, ax = ax)
plt.show()
fig ,ax = plt.subplots()
ax = tips['tip'].plot.kde()
plt.show()
fig, ax = plt.subplots()
ax = tips.plot.scatter(x = 'total_bill', y = 'tip', ax = ax)
plt.show()
fig, ax = plt.subplots()
ax = tips.plot.hexbin(x = 'total_bill', y = 'tip', ax = ax)
plt.show()
fig, ax = plt.subplots()
ax = tips.plot.hexbin(x = 'total_bill', y = 'tip', ax = ax, gridsize = 10)
plt.show()
fig, ax = plt.subplots()
ax = tips.plot.box(ax = ax)
plt.show()