![](/img/trans.png)
[英]Python plotting dataframe with list cells using Seaborn Relplot
[英]Something similar to relplot and displot for plotting boxplot with Seaborn
在 Seaborn relplot和displot中,有一个名为col_wrap
的设置,可以启用多个轴排列在对应于变量级别的行和列的网格中。
虽然relplot
可以选择plot
scatter
和line
,但displot
可以选择 plot hist
, kde
, ecdf
。
目前,我必须依赖以下代码来 plot 网格对应于变量级别的行和列
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="ticks")
tips = sns.load_dataset("tips")
plt.figure(figsize=(15,10))
variables=['Lunch','Dinner']
for i, c in enumerate(variables, 1):
filter_ch = tips ["time"].isin ( [c] )
dv = tips [filter_ch].reset_index ( drop=True )
plt.subplot(2,1,i)
g = sns.boxplot(x='sex', y="total_bill",hue='day',data=dv)
plt.show()
我已经在网上搜索类似于relplot
和displot
的东西来绘制boxplot
,但无济于事。 如果存在这种方法,如果有人可以指导我找到适当的材料,我将不胜感激。
此外,是否有比使用上述建议的代码更紧凑和更合适的方法,因为在实际实践中, variables
将超过两个?
显然,诀窍是使用catplot
sns.catplot(data=tips, x="sex", y="total_bill", hue="day", col="time", kind="box",col_wrap=1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.