# coding=utf-8import pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as pltpd.set_option('display.max_columns', None)pd.set_option('display.width', None)plt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签plt.rcParams['font.serif'] = ['KaiTi']plt.rcParams['axes.unicode_minus'] = Falsetips = sns.load_dataset("tips")print(tips.head())fig, axes =plt.subplots(1,6)sns.boxplot(x=tips["total_bill"],ax=axes[0])sns.boxplot(y=tips["total_bill"],ax=axes[1])sns.boxplot(x="day", y="total_bill", data=tips,ax=axes[2])sns.boxplot(x="day", y="total_bill", hue="smoker", data=tips, palette="Set3",ax=axes[3])sns.boxplot(x="day", y="total_bill", hue="time",data=tips, linewidth=2.5,ax=axes[4])sns.boxplot(data=tips, orient="h", palette="Set2",ax=axes[5])plt.show()
箱线图的概念:
程序执行结果: