I've read the several threads about plotting grouped Seaborn Boxplots, but I was wondering, if there is a simpler solution as a one-liner?
The Pandas Dataframe contains something along the lines of:
Index xaxis yaxis1 xayis2
0 A 30 1985
1 A 29 2002
2 B 21 3034
3 A 31 2087
4 B 19 2931
5 B 21 2832
6 A 28 1950
sns.boxplot(x='xaxis', y=['yaxis1','yaxis2'], data=df);
doesn't work (for probably obvious reasons), while
sns.boxplot(x='xaxis', y='yaxis1', data=df);
or
sns.boxplot(x='xaxis', y='yaxis2', data=df);
work just fine for the separate plots. I also tried using
sns.boxplot(df['xaxis'], df[['yaxis1','yaxis2']])
but no luck therewith either...
I want both yaxis
columns combined into a single boxplot, similar to this one https://seaborn.pydata.org/examples/grouped_boxplot.html, but I can't use hue=
, as the data for both y axes is continuous.
Any way I can do that with the one line sprint, or is it inevitable to run the whole marathon?
sns.boxplot(data=df[['xaxis', 'yaxis1', 'yaxis2']])
should work, but it is unclear what your are expecting. – JohanC