Distribution plots

distplot, joinplot, pairplot

import seaborn as sns
import numpy as np
df = sns.load_dataset("tips")
df.head()  # tip is dependent feature
           # others are independent features
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
df.dtypes
total_bill     float64
tip            float64
sex           category
smoker        category
day           category
time          category
size             int64
dtype: object

Correlation with Heatmap

df.corr() # correlarion can only be found out if values are floating point or integers

# corr values range b/w -1 to +1
total_bill tip size
total_bill 1.000000 0.675734 0.598315
tip 0.675734 1.000000 0.489299
size 0.598315 0.489299 1.000000

Observations :- 1) +ve corr ->> Total bill inc then tip will also inc

sns.heatmap(df.corr())
<matplotlib.axes._subplots.AxesSubplot at 0x2d218d27108>

JointPlot

Univariate analysis

sns.jointplot(x='tip',y='total_bill',data=df,kind='hex') # hex=hexagonal shape
<seaborn.axisgrid.JointGrid at 0x2d219541988>
sns.jointplot(x='tip',y='total_bill',data=df,kind='reg') # reg gives probablity density line(on graph) and regression line (inside plot)
<seaborn.axisgrid.JointGrid at 0x2d2197b6d88>

Pair plot

same data row is matched with another variable's value

sns.pairplot(df, hue='sex')
<seaborn.axisgrid.PairGrid at 0x2d219f05bc8>

Dist Plot

sns.distplot(df['tip'])
<matplotlib.axes._subplots.AxesSubplot at 0x2d21a51bcc8>
sns.distplot(df['tip'],kde =False,bins=10)
<matplotlib.axes._subplots.AxesSubplot at 0x2d21a657dc8>

Categorical Plots

Count Plot

sns.countplot('sex',data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x2d21a6d2688>

Bar Plot

sns.barplot(x='total_bill',y='sex',data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x2d21b8f2788>

Box Plot

sns.boxplot('sex', 'total_bill', data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x2d21b950348>
sns.boxplot(x='day', y='total_bill', data=df, palette='rainbow')
<matplotlib.axes._subplots.AxesSubplot at 0x2d21b9b9a48>
 sns.boxplot(data=df, orient='v')
<matplotlib.axes._subplots.AxesSubplot at 0x2d21baf1708>
 sns.boxplot(x='total_bill', y='day', hue='smoker', data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x2d21bb73288>

Violin Plot

sns.violinplot(x="total_bill",y='day',data=df, palette='rainbow')
<matplotlib.axes._subplots.AxesSubplot at 0x2d21bc73488>