Python 如何更改seaborn catplot中的数字或行和列

Python 如何更改seaborn catplot中的数字或行和列,python,data-visualization,seaborn,facet-grid,catplot,Python,Data Visualization,Seaborn,Facet Grid,Catplot,我有一个如下所示的数据帧: 有几个不同的型号名称。 我尝试使用以下代码在seaborn catplot中绘制数据: sns.set(style="whitegrid") sns.catplot(x='model_name', y='score', hue='train_val_test', col='score_name', data=classification_scores, kind='bar', height=4, aspect=.8) 以

我有一个如下所示的数据帧:

有几个不同的型号名称。 我尝试使用以下代码在seaborn catplot中绘制数据:

sns.set(style="whitegrid")
sns.catplot(x='model_name', y='score', hue='train_val_test', col='score_name',
            data=classification_scores, kind='bar', height=4, aspect=.8)
以下是我得出的图表:

如何更改格式,使图形显示在2x2网格上?把它们都排在一行太拥挤了

import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(16,10))
sns.set(style="whitegrid")

for ax_num, score in zip(range(1,5), ['f1', 'recall', 'accuracy', 'precision']):
    plt.subplot(2,2,ax_num)
    sns.barplot(x='model_name', y='score', hue='train_val_test',
                data=classification_scores[classification_scores['score_name'] == score])
    plt.xticks(rotation=15, fontsize=14)
    
plt.tight_layout()

使用参数
col\u wrap
row\u wrap
设置所需的列数/行数。即

sns.catplot(
    x='model_name',
    y='score',
    hue='train_val_test',
    col='score_name',
    col_wrap=3, #Set the number of columns you want.
    data=classification_scores,
    kind='bar',
    height=4,
    aspect=.8
)
共3列。类似地,如果使用
row
进行分类,则相应的变量称为
row\u wrap