Jovian
⭐️
Sign In
In [1]:
#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
In [2]:
#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')
Out[2]:
[Text(0, 0.5, 'WT'), Text(0.5, 0, 'MPG')]
Notebook Image
In [3]:
#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)

Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6cf6d848>
Notebook Image
In [4]:
#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')
Out[4]:
[Text(0, 0.5, 'Frequency'), Text(0.5, 0, 'Response Time')]
Notebook Image
In [5]:
#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)
Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6e43dcc8>
Notebook Image
In [6]:
#Setting the Labels of a Seaborn Bar Plot
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))
ax = sns.barplot(x="cyl", y="mpg", data=df_grpd)
ax.set(xlabel='Cylinders', ylabel='Number of Cars for Each Cylinder')
Out[6]:
[Text(0, 0.5, 'Number of Cars for Each Cylinder'), Text(0.5, 0, 'Cylinders')]
Notebook Image
In [7]:
#Time Series Plots using Seaborn
import pandas as pd
import seaborn as sns


train_data = "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-26/full_trains.csv"
df = pd.read_csv(train_data)

fig = plt.figure(figsize=(12, 8))
sns.lineplot(x="month", y="total_num_trips", 
             ci=None, data=df)
Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6e83c648>
Notebook Image
In [8]:
#Grouped Time Series Plots using Seaborn
import pandas as pd
import seaborn as sns

df = pd.read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-26/full_trains.csv")

fig = plt.figure(figsize=(12, 8))
sns.lineplot(x="month", y="total_num_trips", hue="departure_station", 
             ci=None, data=df[df.departure_station.str.contains('PARIS')])
Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6e8113c8>
Notebook Image
In [9]:
#Box 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)

fig = plt.figure(figsize=(12, 8))
sns.boxplot(x="vs", y='wt', data=df)
Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6ed0afc8>
Notebook Image
In [10]:
#Heat Map 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)

fig = plt.figure(figsize=(12, 8))
ax = sns.heatmap(df[['mpg', 'disp', 'hp', 'drat', 'wt', 'qsec']])

Notebook Image
In [11]:
#Correlogram in Python
import numpy as np
import pandas as pd
import seaborn as sns

# Correlation matrix
corr = df.corr()

mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True


fig = plt.figure(figsize=(12, 8))
sns.heatmap(corr, mask=mask, vmax=.3, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})
Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6ef20bc8>
Notebook Image
In [12]:
#Violin 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)
fig = plt.figure(figsize=(12,8))
sns.violinplot(x="vs", y='wt', data=df)
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x24c6f124808>
Notebook Image
In [ ]:
import jovian
jovian.commit()
[jovian] Saving notebook..
In [ ]: