# seaborn violin plot

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline

"""
Explanation: Title: Violin Plot using Python, matplotlib and seaborn
Date: 2017-10-21 16:00
Import the necessary packages
Pandas is used to read in the .csv data. Seaborn to build the plot and Matplotlib for displaying the plot.
End of explanation
"""


df = pd.read_csv('data.csv')

"""
Explanation: Read in the .csv data file
Use pandas pd.read_csv() function to read in the .csv file
End of explanation
"""


ax = sns.violinplot(data=df, palette="pastel")
plt.show()

"""
Explanation: Build the violin plot
Use seaborns built-in violin plot function to make the plot. The two fuction arguments are data=df and pallette="pastel".
End of explanation
"""


fig = ax.get_figure()
fig.savefig('sns_violin_plot.png', dpi=300)

#seaborn violin plot

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

df = pd.read_csv('data.csv')

ax = sns.violinplot(data=df, palette="pastel")

fig = ax.get_figure()
fig.savefig('sns_violin_plot.png', dpi=300)

"""
Explanation: Save the figure
Save the figure using matplotlib's ax.get_figure() method and fig.savefig() method. Since seaborn produces a matplotlib axis object, we can use matplotlib methods on our ax object.
End of explanation
"""


