I'm wanting to add a horizontal line i.e. a 'target' line to some plots: stripplots, boxplots, and violin plots, to show ideal values data (or ideally a range).
This R example (Add multiple horizontal lines in a boxplot) - the first image - is basically it (although i'd do some formatting to make presentable).
R abline() equivalent in Python doesn't help me (or I havent figured out how) as I'm using categorical data, so I just want to essentially define (e.g.) y=3
and plot this.
My code (below) works fine, I just don't know how to add a line.
fig, ax = plt.subplots(nrows=4,figsize=(20,20))
sns.violinplot(x="Wafer", y="Means", hue='Feature',
data=Means[Means.Target == 1], ax=ax[0])
sns.violinplot(x="Wafer", y="Means", hue='Feature',
data=Means[Means.Target == 3], ax=ax[1])
sns.boxplot(x="Feature", y="Means",
data=Means, linewidth=0.8, ax=ax[2])
sns.stripplot(x="Feature", y="Means", hue='Wafer',
data=Means, palette="plasma", jitter=0.1, size=5.5, ax=ax[3])
Any help greatly appreciated.
plt.hlines(y, xmin, xmax)
– Stratfordonavon