This is not possible in Seaborn, the reason seems to be that it would interfere with the nested grouping from the hue=
parameter, as indicated to in the changelog describing why this functionality was removed from the sns.violinplot
, which used to have a positions=
keyword (as do plt.boxplot
).
As indicated in the comments, it is possible to achieve the desired outcome using plt.errorbar
.
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
tips = sns.load_dataset('tips')
tips.loc[(tips['size'] == 6), 'size'] = 7
# This is to avoid that the points from the different curves are in the
# exact same x-position (so that the error bars to not obfuscate each other)
offset_amount = 0.1
gender_groups = tips.groupby('sex')
num_groups = gender_groups.ngroups
lims = num_groups * offset_amount / 2
offsets = np.linspace(-lims, lims, num_groups)
# Calculate and plot the mean and error estimates.
fig, ax = plt.subplots()
for offset, (gender_name, gender) in zip(offsets, gender_groups):
means = gender.groupby('size')['total_bill'].mean()
errs = gender.groupby('size')['total_bill'].sem() * 1.96 #95% CI
ax.errorbar(means.index-offset, means, marker='o', yerr=errs, lw=2)
