Catplot with Seaborn, side by side

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-05 08:41:54

问题


I'm using this code below to plot a catplot with Seaborn. Its working ok.

sns.catplot(data=df_gol,
            x='MODALIDADE_DO_VOO',
            y='VALOR',row='DESTINO',
            kind='box',height=3, aspect=1,
            color='red')

But I am getting each box-plot stacked.

Box-plot

I'd like to plot it side by side. How can I do that?

My DF (df_gol) has these values:

Column DESTINO - ['JPA', 'FOR', 'SSA', 'AJU']
Column MODALIDADE_DO_VOO - ['Direto', '1 parada']
Columns VALOR is float type

I've been looking for some examples but I didn't understand how to do it.

Thanks.


回答1:


use the col= keyword instead of the row= to organize your subplots in columns. You can adjust the number of plots per row by using the col_wrap= argument.

sns.catplot(data=df_gol,
            x='MODALIDADE_DO_VOO',
            y='VALOR',col='DESTINO',       # <--- replaced row= by col=
            kind='box',height=3, aspect=1,
            color='red')


来源:https://stackoverflow.com/questions/62312820/catplot-with-seaborn-side-by-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!