I have a dataset which has some outliers and I would like annotate the bottom leg of the box plot in Python. Here is an example of what I face right now:
data = {'theta': [1 for i in range(0,10)],
'error': [10,20,21,22,23,24,25,26,27,28]}
df = pd.DataFrame(data=data)
df
fig,ax1 = plt.subplots(figsize=(8,5))
box_plot = sns.boxplot(x="theta", y='error', data=df, ax = ax1, showfliers = False)
min_value = df.groupby(['theta'])['error'].min().values
for xtick in box_plot.get_xticks():
idx = df[df['error']==min_value[xtick]].index.values
text = 'The minimum value before outliers is here'
box_plot.text(xtick,min_value[xtick]+2, text,
horizontalalignment='center',size='x-small',weight='semibold')
box_plot.plot(xtick,min_value[xtick], marker='*', markersize=20 )
This does not produce what I want
Instead, I would like to get this
Which I can get manually for this example, but I'd like a more systematic approach that I can generalize to other instances.