pandas 中的双变量绘图
同时比较多个变量也是理解数据的一个有用方法。 当有 2 个连续变量时,通常使用散点图。
# 散点图
df.plot(x='x_column', y='y_column', kind='scatter')
plt.show()
当比较 1 个连续变量与 1 个分类变量时,可以使用箱线图。不过,这里需要使用 .boxplot() 方法,而不是 .plot() 方法。
# 箱线图
df.boxplot(column='y_column', by='x_axis')
plt.show()
本练习是课程的一部分
面向 R 用户的 Python
交互式实操练习
通过完成这段示例代码来试试这个练习。
import matplotlib.pyplot as plt
# Scatter plot between the tip and total_bill
tips.plot(____, ____, ____)
plt.show()