简体   繁体   中英

changing the height of p values statannotations above the graph (Python)

I am trying to use statannotations set_pvalue to draw p values above matplotlib.pyplot graphs. The p values are drawn too low and I want to move them higher, but still inside the chart box.

Graph with too low p value annotation:

p 值注释太低的图

Here is the annotation code:

from statannotations.Annotator import Annotator
import matplotlib.pyplot as plt

f, ax = plt.subplots()

# here I draw the graph

annotator = Annotator(ax, pairs=significant_pairs, data=curr_df, x=group_column, y=selected_colunmn, 
                                  order = groups_order)
annotator.set_pvalues(p_val_list)
annotator.configure(loc='inside', fontsize=25)
annotator.annotate()

Thanks

I looked into this package recently, and I will share the line of code from the 'docs' explanation that allows them to do what you are asking. I'll also share the link to that page if you would like to check it out.

annot.configure(test='Mann-Whitney', text_format='star', loc='outside', verbose=2)

The key difference between ^ this line and your annot.configure() is "loc='outside'". Try this out. I think this is the issue.

https://github.com/trevismd/statannotations/blob/master/usage/example.ipynb

Also, I just saw this question literally right now so I deeply apologize if this advice is later than you wanted:)

You should be able to configure that spacing by specifying line_offset_to_group=x to annotator.annotate() .

The default value for x is 0.05 or 0.06 , so you could try 0.15 and see where that leads you.

By lack of a better reference for now, the function signature in the repo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM