I'm looking to show a violin plot of peoples ages, each belonging to either class 0 or 1. I have created a list of ages, and a seperate list corresponding to class. I am able to plot a violin plot for a single list, but how can I plot the age distribution seperated by class 1 and 0?
import numpy as np
import seaborn as sns
import csv
import matplotlib.pyplot as plt
reader = csv.reader(file)
ages = []
class = []
#Here we populate our list with data from our csv
for column in reader:
ages.append(column[3])
class.append(column[0])
#Here we can initialize Figure and Axes object
fig, ax = plt.subplots()
#Here we create our violin plot for the age distribution
ax.violinplot(ages, vert=False)
#
# Here we need to add code to plot age distribution seperated by class
#
#Here we show our violin plot
plt.show()