Open JohannesWiesner opened 1 year ago
Doesn't plt.title
work in all cases? The parameter could be a shortcut to that when one does not need more customization?
In my case plt.title()
is "agnostic" to the annotations generated by statannotations
which leads to an overlap on top of the plot.
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')
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.
Your case is clear, it's a valid request!
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.