Open juuf opened 1 year ago
Here is an MWE
import seaborn as sns
from statannotations.Annotator import Annotator
sns.set_theme(style="ticks",rc={"axes.spines.right": False, "axes.spines.top": False}, font_scale=.8)
df = sns.load_dataset("penguins")
ax=sns.barplot(data=df, x="island", y="body_mass_g")
order = ["Torgersen","Biscoe","Dream"]
pairs=[("Torgersen", "Biscoe"), ("Torgersen", "Dream"), ("Biscoe", "Dream")]
annotator = Annotator(ax, pairs, data=df, x="island", y="body_mass_g", order=order)
annotator.configure(test='Mann-Whitney', text_format='star', loc='inside')
annotator.apply_and_annotate()
ax.set_ylim(0, 5.77e3) # change y-limits to not compress error bars too much
ax.set_box_aspect(1)
Hi,
I encountered the same problem. That's because clipping is not set for loc=inside
You can resolve it by adding "clip_on=False" in Annotator.py line 690.
def _plot_line(self, line_x, line_y):
if self.loc == 'inside':
self.ax.plot(line_x, line_y, lw=self.line_width, c=self.color, clip_on=False)
Hi, thanks for pointing this out. It did the trick!
While having the
loc=inside
option set, is it possible to show the annotations outside of the y-axis limit? I tried to do that by changing the y limits after using statannotations, because else the axis limits are increased, causing the bars to shrink too much (see below).Unfortunately, by changing the limits afterwards the brackets are not displayed anymore. Do you know what is causing that?![image](https://user-images.githubusercontent.com/47811956/200283735-8c1b7de1-55d4-4775-b93c-935215d60515.png)