Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am working on seaborn on jupyter notebook, I am trying to get the mean of each category (x=ks2). I am not able to achieve it in seaborn. I am able to remove the inner="box" but when try replacing with the marker I am not able to.

import seaborn as sns

import pandas as pd

import matplotlib.pyplot as plt

sns.set(style="whitegrid", palette="pastel", color_codes=True)

# Load the dataset

# df = pd.read_csv("science.csv")  << loaded from csv

df = pd.DataFrame({'ks2': [1, 1, 2,3,3,4], 

                   'science': [40, 50, 34,20,0,44]})

# Draw a nested violinplot and split the violins for easier comparison

sns.violinplot(x="ks2", y="science", data=df, split=True,

               inner="box",linewidth=2)

sns.despine(left=True)

plt.savefig('plot.png')

1 Answer

0 votes
by (36.8k points)

You can try this code as shown below:

from numpy import mean

and then overlap it with 

sns.pointplot(x = 'ks2', y='science', data=df, estimator=mean)

then try playing with line styles

Learn Python for Data Science Course to improve your technical knowledge.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...