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

Allow to add title #119

Open
JohannesWiesner opened this issue Apr 6, 2023 · 4 comments
Open

Allow to add title #119

JohannesWiesner opened this issue Apr 6, 2023 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@JohannesWiesner
Copy link

It would be nice to be able to add a plot title on top of all the annotations. Something like:

statannotations.Annotator.Annotator.configure(title='foobar',...)

I guess the function would somehow have to take into account if annotations are to the left and the right (in this case the top is free and the title can be simpled added by using ax.set_tile('foobar')). If the annotations are on the top then the function would have to check where the upper end of the annotations lies and put the title there.

@trevismd
Copy link
Owner

Doesn't plt.title work in all cases? The parameter could be a shortcut to that when one does not need more customization?

@JohannesWiesner
Copy link
Author

In my case plt.title() is "agnostic" to the annotations generated by statannotations which leads to an overlap on top of the plot.

@JohannesWiesner
Copy link
Author

Example:

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

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)
pairs=[("Thur", "Fri"), ("Thur", "Sat"), ("Fri", "Sun")]
annotator = Annotator(ax, pairs, data=df, x=x, y=y, order=order)
annotator.configure(test='Mann-Whitney', text_format='star', loc='outside')
annotator.apply_and_annotate()
plt.title('tips')

image
As you can see plt.title() is not "aware" of the fact that there are already annotations generated by statannotations and therefore will just brute-force plot the title on top of the annotations.

@trevismd
Copy link
Owner

trevismd commented Jun 9, 2023

Your case is clear, it's a valid request!

@trevismd trevismd added enhancement New feature or request good first issue Good for newcomers labels Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants