Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlaying actual data on a boxplot from a pandas dataframe

I am using Seaborn to make boxplots from pandas dataframes. Seaborn boxplots seem to essentially read the dataframes the same way as the pandas boxplot functionality (so I hope the solution is the same for both -- but I can just use the dataframe.boxplot function as well). My dataframe has 12 columns and the following code generates a single plot with one boxplot for each column (just like the dataframe.boxplot() function would).

fig, ax = plt.subplots()
sns.set_style("darkgrid", {"axes.facecolor":"darkgrey"})
pal = sns.color_palette("husl",12)
sns.boxplot(dataframe, color = pal)

Can anyone suggest a simple way of overlaying all the values (by columns) while making a boxplot from dataframes? I will appreciate any help with this.

like image 481
geog_newbie Avatar asked Feb 13 '23 05:02

geog_newbie


1 Answers

This hasn't been added to the seaborn.boxplot function yet, but there's something similar in the seaborn.violinplot function, which has other advantages:

x = np.random.randn(30, 6)
sns.violinplot(x, inner="points")
sns.despine(trim=True)

enter image description here

like image 170
mwaskom Avatar answered Feb 15 '23 20:02

mwaskom