Christopher Creveling
Christopher Creveling

Reputation: 351

Using statannotations how can I pass in stats_params to modify the statistics test?

I'm trying to perform a one-tailed students t-test_ind and need to modify the stats_params but am unable to do so.

Here is the code I'm using:

plotting_parameters = {
    'data':        df1, 
    'x':           R, 
    'y':           TMD, 
    'hue':         None, #R, 
    'hue_order':   None, #[Eq, Po], 
    'order':       [Eq, Po], 
    'ci':          'sd', 
    'errcolor':    'black', 
    'capsize':     0.2, 
}

annotator_parameters = {
    'loc':                  'outside', 
    'test':                 't-test_ind', 
    'text_format':          'star', 
    'line_offset':          0.0, 
    'line_height':          0.015, 
    'stats_params':         {'alternative': 'greater'}
}

pairs                 = [((Eq, Po))]

# Barplot
f, ax = plt.subplots()
ax = sns.barplot(**plotting_parameters)

annotator = Annotator(ax, pairs, **plotting_parameters)

annotator.configure(**annotator_parameters)
annotator.apply_and_annotate()

ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax = sns.despine() # takes the lines off on the right and top of the graph

inside the dictionary annotator_parameters the variable stats_params doesn't seem to be passed through to scipy.stats.

Am I doing something incorrectly?

When I used to use statannot I would pass the variable through and was able to get it to work.

Thanks in advance!

Upvotes: 1

Views: 664

Answers (1)

Stef
Stef

Reputation: 30579

You need to supply stats_params to the apply_test method, not the configure method. Unfortunately, the apply_and_annotate method doesn't take parameters, so you'll have to call apply_test and annotate individually:

annotator.apply_test(alternative='greater')
annotator.annotate()

Upvotes: 4

Related Questions