Created
February 16, 2023 16:35
-
-
Save muhammadanas0716/8e490d0ff67d9791c240260b9eb93ec7 to your computer and use it in GitHub Desktop.
Violin plots are used to visualize the distribution of a continuous variable. They are similar to box plots, but provide more information about the shape and density of the distribution. In a violin plot, a kernel density plot is drawn on each side of a central box. The box represents the interquartile range (IQR) of the data, with the median sh…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libs | |
import numpy as np | |
import pandas as pd | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# Import Data | |
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mpg_ggplot2.csv") | |
# Draw Plot | |
plt.figure(figsize=(13,10), dpi= 80) | |
sns.violinplot(x='class', y='hwy', data=df, scale='width', inner='quartile') | |
# Decoration | |
plt.title('Violin Plot of Highway Mileage by Vehicle Class', fontsize=22) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment