Statannotation mislocation of statistical significance

25 views Asked by At

I drawed boxplot using seaborn and tried to add statistical significance using statannotations module. But, unexpectedly, the starisk marker has been located incorrectly.

Boxplot without statannotations: boxplot without statannotations

Boxplot with statannotations: boxplot with statannotations

I also attached my codes.

Thank you.

fig, axs = plt.subplots(2, 4, figsize=(17, 8))

feature = 'A'

pairs = [[(feature, 'Cluster A'), (feature, 'Cluster B')],
         [(feature, 'Cluster B'), (feature, 'Cluster C')],
         [(feature, 'Cluster A'), (feature, 'Cluster C')],
        ]
pvals = get_pvals(df_sp_melt_feature)

plotting_parameters = {'data':    df_sp_melt_feature,
                        'x':       'feature_names',
                        'y':       'vals',
                        'hue':     'cluster',
                        }

with sns.plotting_context('notebook'):

    sns.boxplot(ax=axs.flat[i], showfliers=True, **plotting_parameters)

    annotator = Annotator(axs.flat[i], pairs, verbose=False, **plotting_parameters);
    annotator.set_pvalues(pvals);
    annotator.configure(loc='inside') # text_offset=3
    annotator.annotate();

    axs.flat[i].set_xlabel('')
    axs.flat[i].set_ylabel('')
    axs.flat[i].set_xticklabels([feature], fontsize=12)

I would like to locate the statannotations in a proper location.

0

There are 0 answers