Seaborn-Multiple Violin Plots Padhai - Class Work
Padiah_MultipleViolinPlots

Multiple Violin Plots with Seaborn - Penguin dataset

In [ ]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes = True)
In [ ]:
pen = sns.load_dataset('penguins')
In [ ]:
pen.head(2)
Out[ ]:
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
0 Adelie Torgersen 39.1 18.7 181.0 3750.0 Male
1 Adelie Torgersen 39.5 17.4 186.0 3800.0 Female
In [ ]:
sns.violinplot( data=pen, x='body_mass_g', orient='v');
/usr/local/lib/python3.7/dist-packages/seaborn/_core.py:1326: UserWarning: Vertical orientation ignored with only `x` specified.
  warnings.warn(single_var_warning.format("Vertical", "x"))
In [ ]:
sns.violinplot(x='species', y='body_mass_g', data=pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83ac36550>
In [ ]:
pen.head(2)
Out[ ]:
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
0 Adelie Torgersen 39.1 18.7 181.0 3750.0 Male
1 Adelie Torgersen 39.5 17.4 186.0 3800.0 Female
In [ ]:
sns.violinplot(x='species', y='bill_depth_mm', data=pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83abb6d10>
In [ ]:
sns.violinplot(x='species', y='flipper_length_mm', data=pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83ab412d0>
In [ ]:
pen.head(2)
Out[ ]:
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
0 Adelie Torgersen 39.1 18.7 181.0 3750.0 Male
1 Adelie Torgersen 39.5 17.4 186.0 3800.0 Female
In [ ]:
sns.violinplot(x='species', y='flipper_length_mm', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83a6ea890>
In [ ]:
sns.violinplot(x='island', y='flipper_length_mm', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83a5e19d0>
In [ ]:
sns.violinplot(x='sex', y='flipper_length_mm', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83a55e710>
In [ ]:
sns.swarmplot(x='island', y='flipper_length_mm', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa837bb82d0>
In [ ]:
sns.violinplot(x='island', y='flipper_length_mm', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa837c373d0>
In [ ]:
sns.swarmplot(x='island', y='flipper_length_mm', hue = 'sex', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa837b2e310>
In [ ]:
sns.swarmplot(x='island', y='flipper_length_mm', hue = 'species', data = pen)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa837a9f790>
In [ ]:
d = sns.load_dataset('diamonds')
In [ ]:
d.head(2)
Out[ ]:
carat cut color clarity depth table price x y z
0 0.23 Ideal E SI2 61.5 55.0 326 3.95 3.98 2.43
1 0.21 Premium E SI1 59.8 61.0 326 3.89 3.84 2.31
In [ ]:
sns.swarmplot(x='cut', y='price', data = d.sample(1000))
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 50.9% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 27.2% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 27.7% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 8.8% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa83a4a7a50>
In [ ]:
sns.swarmplot(x='cut', y='price', hue = 'color', data = d.sample(1000))
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 51.4% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 31.2% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
/usr/local/lib/python3.7/dist-packages/seaborn/categorical.py:1296: UserWarning: 32.0% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.
  warnings.warn(msg, UserWarning)
Out[ ]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa8360e6c10>
In [ ]: