Is there a way to align the mean+SEM of a pointplot and the corresponding swarmplot?
Here is my code:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
n=200
to_plot = np.random.uniform(low=0.0, high=1.0, size=n)
mods = ['a','b']
model_col = mods*(n/2)
opt=['1']*(n/2)+['2']*(n/2)
d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)}
df = pd.DataFrame(d)
sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075'])
sns.pointplot(x="Model", y="Par", hue='opt', data=df,join=False,dodge=True,
ci=68,n_boot=1000,capsize=0.1,errwidth=0.5,scale = 1.5,palette=['k','k'])
ax.get_legend().remove()
plt.show()
Here is my plot:
It seems swarmplot
and pointplot
use different defaults for their respective dodge
paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)