If I a have data like a bunch of classes where each class can have a different number of students, and each student has a grade (0-100), for example like this:

tdf = pd.DataFrame({'classes':["a", "a", "a", "b", "b", "b","b","b", "c", "c"],
                    'grades':[78, 28, 10, 3, 79, 91, 65, 51, 75, 89]})

What is the best way to visualize the range of grades within each class? I want to show that in class A, there is a range between 10 and 78, in B there is 3 and 91, in C there is 75 and 89. I was thinking of boxplot or violin plot but when I tried them I am not really sure. Is there such thing as a bar chart that can show range? Will that make sense?

I am not sure if this is the right place to ask, so here I am.


1 Answer 1


I believe boxplot or violin plot is a good idea and you could overlay datapoints with a bit of jitter to the former. See below an example in seaborn taken from a relevant question:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.violinplot(x="day", y="total_bill", data=tips, color="0.8")
sns.stripplot(x="day", y="total_bill", data=tips, jitter=True, zorder=1)

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.