Learn practical skills, build real-world projects, and advance your career
#Scatter Plot in Python using Seaborn
%matplotlib inline

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

# Suppress warnings
import warnings
warnings.filterwarnings('ignore')

# Optional but changes the figure size
fig = plt.figure(figsize=(12, 8))

df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/mtcars.csv')

ax = sns.regplot(x="wt", y="mpg", data=df)
Notebook Image
#Changing the Labels on a Seaborn Plot
import pandas as pd
import seaborn as sns

fig = plt.figure(figsize=(12, 8))
ax = sns.regplot(x="wt", y="mpg", ci=False, data=df)
ax.set(xlabel='MPG', ylabel='WT')
[Text(0, 0.5, 'WT'), Text(0.5, 0, 'MPG')]
Notebook Image
#Histogram in Python using Seaborn
import pandas as pd
import seaborn as sns

df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/airquality.csv')

fig = plt.figure(figsize=(12, 8))
sns.distplot(df.Temp, kde=False)
<matplotlib.axes._subplots.AxesSubplot at 0x24c6cf6d848>
Notebook Image
#Grouped Histogram in Seaborn
import pandas as pd
import seaborn as sns

df = pd.read_csv('https://raw.githubusercontent.com/marsja/jupyter/master/flanks.csv', 
                 index_col=0)

fig = plt.figure(figsize=(12, 8))
for condition in df.TrialType.unique():
    cond_data = df[(df.TrialType == condition)]
    ax = sns.distplot(cond_data.RT, kde=False)

ax.set(xlabel='Response Time', ylabel='Frequency')
[Text(0, 0.5, 'Frequency'), Text(0.5, 0, 'Response Time')]
Notebook Image
#Bar Plots in Python using Seaborn
import pandas as pd
import seaborn as sns

df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/mtcars.csv', index_col=0)

df_grpd = df.groupby("cyl").count().reset_index()

fig = plt.figure(figsize=(12, 8))
sns.barplot(x="cyl", y="mpg", data=df_grpd)
<matplotlib.axes._subplots.AxesSubplot at 0x24c6e43dcc8>
Notebook Image