Skip to content

Instantly share code, notes, and snippets.

View audhiaprilliant's full-sized avatar
🎯
Focusing

Audhi Aprilliant audhiaprilliant

🎯
Focusing
View GitHub Profile
@audhiaprilliant
audhiaprilliant / matplotlib-102-subplot-3.py
Created November 11, 2022 17:02
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- SUBPLOT (2 ROWS, 2 COLUMNS) ----------
# Create a grid for plots (2 rows & 2 columns)
fig, ax = plt.subplots(nrows = 2, ncols = 2, figsize = (10, 6))
# Bar plot - 1
ax[0, 0].bar(
x = 'gender',
height = 'customerID',
data = df_group_2,
@audhiaprilliant
audhiaprilliant / matplotlib-102-subplot-2.py
Created November 11, 2022 17:00
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- SUBPLOT (1 ROWS, 2 COLUMNS) ----------
# Create a grid for plots (1 rows & 2 columns)
fig, ((ax1, ax2)) = plt.subplots(nrows = 1, ncols = 2, figsize = (10, 4.8))
# Bar plot - 1
ax1.bar(
x = 'gender',
height = 'customerID',
data = df_group_2,
@audhiaprilliant
audhiaprilliant / matplotlib-102-subplot-1.py
Last active November 11, 2022 17:01
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- SUBPLOT (1 ROWS, 2 COLUMNS) ----------
# Create a grid for plots (1 row & 2 columns)
fig, ax = plt.subplots(nrows = 1, ncols = 2, figsize = (10, 4.8))
# Bar plot - 1
ax[0].bar(
x = 'gender',
height = 'customerID',
data = df_group_2,
@audhiaprilliant
audhiaprilliant / matplotlib-102-multiplot-2.py
Created November 11, 2022 16:58
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- MULTIPLOT ----------
# Create a grid for plots
fig, ax = plt.subplots(figsize = (10, 5))
# Make another axes object for secondary y-Axis
ax2 = ax.twinx()
# Bar plot
ax.bar(
@audhiaprilliant
audhiaprilliant / matplotlib-102-multiplot-1.py
Created November 11, 2022 16:56
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- MULTIPLOT ----------
# Figure size
fig = plt.figure(figsize = (10, 4.8))
# Bar plot
plt.bar(
x = 'PaymentMethod',
height = 'customerID',
data = df_group_1,
@audhiaprilliant
audhiaprilliant / matplotlib-102-dataprep.py
Created November 11, 2022 16:55
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
# ---------- IMPORT PACKAGES ----------
# Dataframe manipulation
import pandas as pd
# Matrices operation
import numpy as np
# Data viz with matplotlib
import matplotlib
@audhiaprilliant
audhiaprilliant / matplotlib-102.ipynb
Last active November 11, 2022 16:51
Matplotlib 102 - Basic Introduction to Multiplot, Subplot and Gridspec
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@audhiaprilliant
audhiaprilliant / matplotlib-101-iteration-7.py
Last active November 9, 2022 14:45
Matplotlib 101 - Basic Introduction for Python Beginner
# ---------- 7th ITERATION - FINAL TOUCH ----------
# Figure size
fig = plt.figure(figsize = (10, 4.8))
# Bar plot
bar_fig = plt.bar(
x = 'PaymentMethod',
height = 'customerID',
data = df_group_1,
@audhiaprilliant
audhiaprilliant / matplotlib-101-iteration-6.py
Last active November 9, 2022 14:44
Matplotlib 101 - Basic Introduction for Python Beginner
# ---------- 6th ITERATION - ADD ANOTHER DATA LABELS ----------
# Figure size
fig = plt.figure(figsize = (10, 4.8))
# Bar plot
bar_fig = plt.bar(
x = 'PaymentMethod',
height = 'customerID',
data = df_group_1,
@audhiaprilliant
audhiaprilliant / matplotlib-101-iteration-5.py
Last active November 9, 2022 14:43
Matplotlib 101 - Basic Introduction for Python Beginner
# ---------- 5th ITERATION - ADD HORIZONTAL LINE ----------
# Figure size
fig = plt.figure(figsize = (10, 4.8))
# Bar plot
bar_fig = plt.bar(
x = 'PaymentMethod',
height = 'customerID',
data = df_group_1,