edit: solved here
seaborn boxplot and stripplot points aren't aligned over the x-axis by hue
In the above case, the swarmplot was shifted in the overlay and the resolution was achieved from setting dodge = true in swarmplot.
Here, the boxplot was shifted, the resolution was achieved from setting dodge = False in barplot.
I have a seaborn boxplot overlayed with a seaborn swarmplot. Whenever I add labels to my boxplot, the legend repositions the boxplot without adjusting the swarmplot (fig 1).
sns.swarmplot(x = 'data_type', y = 'count', data = df,
alpha = .5, palette='colorblind', hue='data_type', legend = 0, zorder=0.5)
ax = sns.boxplot(x = 'data_type', y = 'count', data = df,
palette='colorblind', showfliers = 0, hue = 'data_type')
plt.legend(bbox_to_anchor = (1.02, 1), loc = 'upper left')
If I remove the labels, through omitting
hue = 'data_type'
then I have the alignment I want (fig 2).
How can I display the boxplot legend while preserving alignment?