问题
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.
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