Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide_non_significant kwarg should be configurable #127

Closed
wants to merge 1 commit into from
Closed

hide_non_significant kwarg should be configurable #127

wants to merge 1 commit into from

Conversation

JasonMendoza2008
Copy link
Contributor

hide_non_significant optional kwarg was added to Annotator but wasn't made configurable. This PR aims at fixing this bug.

This worked:

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

sns.set(style="whitegrid")

df = sns.load_dataset("tips")

x = "day"
y = "total_bill"
order = ['Sun', 'Thur', 'Fri', 'Sat']
ax = sns.boxplot(data=df, x=x, y=y, order=order)
annot = Annotator(
    ax,
    [("Thur", "Fri"), ("Thur", "Sat"), ("Fri", "Sun")],
    data=df,
    x=x,
    y=y,
    order=order,
    hide_non_significant=False
)
annot.configure(test='Mann-Whitney', text_format='star', loc='outside', verbose=2)
annot.apply_test()
ax, test_results = annot.annotate()

# show with big margins
plt.subplots_adjust(top=0.80)
plt.show()

This did not but should:

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

sns.set(style="whitegrid")

df = sns.load_dataset("tips")

x = "day"
y = "total_bill"
order = ['Sun', 'Thur', 'Fri', 'Sat']
ax = sns.boxplot(data=df, x=x, y=y, order=order)
annot = Annotator(
    ax,
    [("Thur", "Fri"), ("Thur", "Sat"), ("Fri", "Sun")],
    data=df,
    x=x,
    y=y,
    order=order
)
annot.configure(test='Mann-Whitney', text_format='star', loc='outside', verbose=2, hide_non_significant=False)
annot.apply_test()
ax, test_results = annot.annotate()

# show with big margins
plt.subplots_adjust(top=0.80)
plt.show()

Both work after the PR.
Tests were passed on Python 3.11.1.

I squashed everything like suggested last time I made a PR.

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #127 (68750e8) into dev (4766703) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #127   +/-   ##
=======================================
  Coverage   97.05%   97.05%           
=======================================
  Files          29       29           
  Lines        1936     1936           
=======================================
  Hits         1879     1879           
  Misses         57       57           
Files Changed Coverage Δ
statannotations/Annotator.py 91.48% <ø> (ø)

@trevismd
Copy link
Owner

trevismd commented Oct 1, 2023

Hello @JasonMendoza2008 ,
Thank you for the PR!
I'm sorry I didn't check this sooner. In fact, I discovered it when I tried to update the documentation and add an example, and I implemented it independently.
A few more changes were required as it shouldn't be an argument for Annotator's __init__ at all (because configuring once is also persistent if not updated), and there were no tests checking the parameter at all.
I'm finalizing it and shipping it in v0.6.0.
See you for the next one, I hope :)

@trevismd trevismd closed this Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants