使用seaborn中的catplot()同时绘制多个图
catplot(x=None, y=None, hue=None, data=None, row=None, col=None, col_wrap=None, estimator=<function mean at 0x000002865D33E8C8>, ci=95, n_boot=1000, units=None, order=None, hue_order=None, row_order=None, col_order=None, kind='strip', height=5, aspect=1, orient=None, color=None, palette=None, legend=True, legend_out=True, sharex=True, sharey=True, margin_titles=False, facet_kws=None, **kwargs)
import seaborn as sns
from matplotlib import pyplot as plt
sns.set_style('darkgrid')
tips = sns.load_dataset("tips")
sns.catplot(x="day", y="total_bill", hue="smoker",
col="time", aspect=.6, kind="swarm",
data=tips, legend=True, legend_out=False)
#ax.legend(shadow=False, fancybox=False, ncol=1, fontsize=10, loc='upper left')
plt.show()
import seaborn as sns
from matplotlib import pyplot as plt
sns.set_style('darkgrid')
titanic = sns.load_dataset("titanic")
g = sns.catplot(x="fare", y="survived", row="class",
kind="box", orient="h", height=1.5, aspect=4,
data=titanic.query("fare > 0"))
g.set(xscale="log")
plt.show()
可以通过row,col参数指定要根据什么属性进行分行(列)显示
orient参数可以设置朝向,这通常要结合横纵坐标轴考虑,可以设为'v'或'h'