Reputation: 1684
With the following data (for a quick csv file generation, dataset link):
and the following code:
df_all[['all', 'taste','fruit']].melt('fruit').boxplot(column=['value'], by=['fruit', 'variable'], rot=45, fontsize=11, patch_artist=True,
color=dict(boxes='#053061', whiskers='#67001F', medians='#A7D0E4', caps='#67001F'),
boxprops=dict(linestyle='-', linewidth=0.8),
flierprops=dict(linestyle='-', linewidth=0, marker='+'),
medianprops=dict(linestyle='-', linewidth=0.8),
whiskerprops=dict(linestyle='-', linewidth=0.8),
capprops=dict(linestyle='-', linewidth=0.8),
showfliers=True,
grid=False,)
I get this abomination:
I want to achieve
something like:
Probably it is impossible to achieve an exact output, but any help is really appreciated!
Upvotes: 2
Views: 158
Reputation: 41327
If you're open to using seaborn, you can use sns.boxplot()
and set the melted variable
as hue
:
import seaborn as sns
sns.boxplot(
data=df[['all', 'taste', 'fruit']].melt('fruit'),
x='fruit',
y='value',
hue='variable',
width=0.5,
order=['apple', 'mango', 'orange'],
)
Upvotes: 3