SEABORN - BOXPLOT Padhai ClassWork
Padhai_boxplot

Boxplots with Seaborn

In [2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes = True)
In [3]:
x = np.random.normal(size=1000)

Box Plot

  1. Center line is called MEDIAN
  2. to the left and the right are 25th and 75th quartiles
  3. by default, 1.5 times the distance of the Quartile range to either sides
  4. what ever is outside is called OUT-LIER
  5. boxplot is used to show, where the data is accumulated
  6. in uniform distribution we dont have any outliers as the data is distributed between 0 and 1
  7. data in the box has 50% of the data points, remaining are outside
In [4]:
sns.boxplot(x)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a7b6610>
In [6]:
x = np.random.uniform(size=1000)
In [7]:
sns.boxplot(x)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a6cc3d0>
In [8]:
sns.boxplot(x, whis=0.2)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a6de1d0>
In [9]:
# with normal distribution
x = np.random.normal(size = 1000)
sns.boxplot(x, whis=.2)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a135290>
In [10]:
sns.boxplot(x, whis=.5)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a114dd0>
In [12]:
sns.boxplot(x, whis=.2, fliersize=1)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a0ae7d0>
In [17]:
sns.boxplot(x, whis=0.5, fliersize=1, orient = 'v');
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
/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 [18]:
d = sns.load_dataset('diamonds')
In [19]:
sns.boxplot(d.price)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[19]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a105a10>
In [20]:
sns.histplot(d.price)
Out[20]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc469728dd0>
In [21]:
sns.kdeplot(d.price)
Out[21]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46a003850>
In [22]:
sns.boxplot(d.x)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[22]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc46961fc50>
In [23]:
sns.kdeplot(d.x)
Out[23]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc464cbde50>
In [24]:
sns.boxplot(d.carat)
/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning
Out[24]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc464c78050>
In [25]:
sns.histplot(d.carat)
Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc462f25d90>
In [ ]: