““”

India E-Commerce Capstone Project — All 8 Visualizations MBA Marketing | Manipal University ============================================================ Run this file once after installing the required libraries. All 8 figures will be saved as high-resolution PNG files in a folder called “figures/” in the same directory. ““”

import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.patches as mpatches import matplotlib.ticker as mticker import seaborn as sns from matplotlib.gridspec import GridSpec

── Output folder ────────────────────────────────────────────────

os.makedirs(“figures”, exist_ok=True)

── Global style ─────────────────────────────────────────────────

plt.rcParams.update({ “font.family”: “DejaVu Sans”, “axes.spines.top”: False, “axes.spines.right”:False, “axes.grid”: True, “grid.alpha”: 0.35, “grid.linestyle”: “–”, “figure.dpi”: 150, })

NAVY = “#1B2A4A” GOLD = “#C9A84C” BLUE = “#2E6DB4” GREEN = “#1E7A4E” RED = “#C0392B” PURP = “#8B2FC9” TEAL = “#0097A7” ORNG = “#E67E22”

YEARS = list(range(2015, 2026))

════════════════════════════════════════════════════════════════

FIG 1 — E-Commerce Revenue Growth (Line Chart)

════════════════════════════════════════════════════════════════

revenue = [13.6, 16.0, 20.0, 25.0, 32.7, 46.2, 56.6, 68.0, 83.0, 99.0, 120.0]

fig, ax = plt.subplots(figsize=(11, 6)) ax.plot(YEARS, revenue, color=BLUE, linewidth=2.5, marker=“o”, markersize=7, zorder=3) ax.fill_between(YEARS, revenue, alpha=0.12, color=BLUE)

Annotate COVID spike

ax.annotate(“COVID-19”, xy=(2020, 46.2), xytext=(2021.2, 35), arrowprops=dict(arrowstyle=“->”, color=RED, lw=1.5), fontsize=9, color=RED)

Annotate UPI launch

ax.annotate(“UPI Launch(2016)”, xy=(2016, 16.0), xytext=(2014.8, 26), arrowprops=dict(arrowstyle=“->”, color=GREEN, lw=1.5), fontsize=9, color=GREEN)

for x, y in zip(YEARS, revenue): ax.text(x, y + 2.5, f”${y}B”, ha=“center”, fontsize=7.5, color=NAVY)

ax.set_title(“Figure 1 — India E-Commerce Revenue Growth (2015–2025)”, fontsize=13, fontweight=“bold”, color=NAVY, pad=14) ax.set_xlabel(“Year”, fontsize=11) ax.set_ylabel(“Revenue (USD Billion)”, fontsize=11) ax.set_xticks(YEARS) ax.set_xticklabels(YEARS, rotation=45) ax.set_ylim(0, 140) ax.yaxis.set_major_formatter(mticker.FormatStrFormatter(“$%dB”)) fig.text(0.5, -0.02, “Source: Statista, IBEF | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig1_ecommerce_revenue.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 1 saved”)

════════════════════════════════════════════════════════════════

FIG 2 — Internet & Smartphone Penetration vs E-Commerce Users

════════════════════════════════════════════════════════════════

internet_users = [354, 391, 431, 500, 560, 622, 658, 692, 730, 759, 800] # millions smartphone_users= [220, 264, 312, 370, 435, 500, 550, 600, 650, 700, 748] # millions ecomm_users = [ 58, 75, 96, 120, 150, 190, 220, 260, 300, 340, 380] # millions

fig, ax = plt.subplots(figsize=(11, 6)) ax.plot(YEARS, internet_users, color=BLUE, lw=2.5, marker=“o”, ms=6, label=“Internet Users”) ax.plot(YEARS, smartphone_users, color=GREEN, lw=2.5, marker=“s”, ms=6, label=“Smartphone Users”) ax.plot(YEARS, ecomm_users, color=GOLD, lw=2.5, marker=“^”, ms=7, linestyle=“–”, label=“E-Commerce Users”)

ax.fill_between(YEARS, internet_users, alpha=0.07, color=BLUE) ax.fill_between(YEARS, smartphone_users, alpha=0.07, color=GREEN) ax.fill_between(YEARS, ecomm_users, alpha=0.12, color=GOLD)

ax.set_title(“Figure 2 — Internet & Smartphone Penetration vs E-Commerce Users (2015–2025)”, fontsize=12, fontweight=“bold”, color=NAVY, pad=14) ax.set_xlabel(“Year”, fontsize=11) ax.set_ylabel(“Users (Millions)”, fontsize=11) ax.set_xticks(YEARS) ax.set_xticklabels(YEARS, rotation=45) ax.legend(fontsize=10, framealpha=0.9) fig.text(0.5, -0.02, “Source: TRAI, World Bank | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig2_penetration_vs_users.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 2 saved”)

════════════════════════════════════════════════════════════════

FIG 3 — UPI Transaction Volume & Value (Dual-Axis Line)

════════════════════════════════════════════════════════════════

upi_years = list(range(2017, 2026)) upi_vol = [0.9, 5.4, 10.8, 22.3, 38.7, 74.0, 103.6, 131.6, 172.0] # billion transactions upi_value = [0.07, 0.47, 0.96, 2.11, 4.16, 7.71, 12.35, 18.41, 26.0] # USD trillion

fig, ax1 = plt.subplots(figsize=(11, 6)) ax2 = ax1.twinx() ax2.spines[“right”].set_visible(True) ax2.spines[“top”].set_visible(False)

l1, = ax1.plot(upi_years, upi_vol, color=BLUE, lw=2.5, marker=“o”, ms=6) l2, = ax2.plot(upi_years, upi_value, color=ORNG, lw=2.5, marker=“D”, ms=6, linestyle=“–”)

ax1.fill_between(upi_years, upi_vol, alpha=0.10, color=BLUE) ax2.fill_between(upi_years, upi_value, alpha=0.10, color=ORNG)

ax1.set_ylabel(“Transaction Volume (Billions)”, color=BLUE, fontsize=11) ax2.set_ylabel(“Transaction Value (USD Trillion)”, color=ORNG, fontsize=11) ax1.tick_params(axis=“y”, colors=BLUE) ax2.tick_params(axis=“y”, colors=ORNG) ax1.set_xticks(upi_years) ax1.set_xticklabels(upi_years, rotation=45) ax1.set_xlabel(“Year”, fontsize=11)

ax1.annotate(“COVID-19 boostdigital payments”, xy=(2020, 38.7), xytext=(2018.5, 60), arrowprops=dict(arrowstyle=“->”, color=RED, lw=1.5), fontsize=9, color=RED)

ax1.set_title(“Figure 3 — UPI Transaction Volume & Value (2017–2025)”, fontsize=13, fontweight=“bold”, color=NAVY, pad=14) fig.legend([l1, l2], [“Volume (Bn transactions)”, “Value (USD Trillion)”], loc=“upper left”, bbox_to_anchor=(0.12, 0.88), fontsize=10) fig.text(0.5, -0.02, “Source: Reserve Bank of India (RBI) | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig3_upi_growth.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 3 saved”)

════════════════════════════════════════════════════════════════

FIG 4 — Category-wise Consumer Spending Share (Stacked Bar)

════════════════════════════════════════════════════════════════

cat_years = [2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025] categories = { “Electronics”: [34, 33, 30, 28, 27, 26, 25, 24], “Fashion”: [28, 27, 22, 20, 21, 20, 19, 18], “Grocery”: [ 8, 9, 14, 16, 17, 18, 20, 22], “Travel”: [15, 14, 8, 9, 10, 11, 12, 12], “Health/Beauty”: [ 5, 6, 9, 11, 11, 12, 12, 12], “Others”: [10, 11, 17, 16, 14, 13, 12, 12], } palette = [BLUE, GOLD, GREEN, TEAL, PURP, “#AAAAAA”]

fig, ax = plt.subplots(figsize=(12, 6)) bottoms = np.zeros(len(cat_years)) for (cat, vals), color in zip(categories.items(), palette): ax.bar(cat_years, vals, bottom=bottoms, label=cat, color=color, width=0.65, edgecolor=“white”, linewidth=0.5) for i, (b, v) in enumerate(zip(bottoms, vals)): if v >= 8: ax.text(cat_years[i], b + v/2, f”{v}%“, ha=”center”, va=“center”, fontsize=7.5, color=“white”, fontweight=“bold”) bottoms += np.array(vals)

ax.set_xticks(cat_years) ax.set_xticklabels(cat_years) ax.set_ylabel(“Share of Consumer Spending (%)”, fontsize=11) ax.set_xlabel(“Year”, fontsize=11) ax.set_ylim(0, 110) ax.set_title(“Figure 4 — Category-wise Consumer Spending Share in Indian E-Commerce (2018–2025)”, fontsize=11, fontweight=“bold”, color=NAVY, pad=14) ax.legend(loc=“upper right”, fontsize=9, framealpha=0.9) fig.text(0.5, -0.02, “Source: Statista, IBEF | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig4_category_spending.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 4 saved”)

════════════════════════════════════════════════════════════════

FIG 5 — YoY Growth Rate Pre vs Post COVID (Grouped Bar)

════════════════════════════════════════════════════════════════

growth_years = [2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025] growth_rates = [25.0, 30.8, 41.2, 22.5, 21.4, 15.9, 21.6, 21.2] colors_bar = [GREEN if y < 2020 else RED if y == 2020 else BLUE for y in growth_years]

fig, ax = plt.subplots(figsize=(11, 6)) bars = ax.bar(growth_years, growth_rates, color=colors_bar, width=0.6, edgecolor=“white”, linewidth=0.8)

for bar, rate in zip(bars, growth_rates): ax.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 0.5, f”{rate}%“, ha=”center”, va=“bottom”, fontsize=10, fontweight=“bold”, color=NAVY)

ax.axvline(x=2019.5, color=“grey”, linestyle=“–”, lw=1.5, alpha=0.7) ax.text(2018.2, 43, “Pre-COVID”, fontsize=9, color=GREEN, fontweight=“bold”) ax.text(2020.2, 43, “COVID &-COVID”, fontsize=9, color=BLUE, fontweight=“bold”)

ax.set_xlabel(“Year”, fontsize=11) ax.set_ylabel(“Year-on-Year Growth Rate (%)”, fontsize=11) ax.set_xticks(growth_years) ax.set_ylim(0, 50) ax.set_title(“Figure 5 — YoY E-Commerce Growth Rate: Pre-COVID vs Post-COVID (2018–2025)”, fontsize=11, fontweight=“bold”, color=NAVY, pad=14)

legend_patches = [ mpatches.Patch(color=GREEN, label=“Pre-COVID Growth”), mpatches.Patch(color=RED, label=“COVID Year (2020)”), mpatches.Patch(color=BLUE, label=“Post-COVID Growth”),] ax.legend(handles=legend_patches, fontsize=10) fig.text(0.5, -0.02, “Source: Statista, Ministry of Commerce | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig5_yoy_growth.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 5 saved”)

════════════════════════════════════════════════════════════════

FIG 6 — Top 10 States by E-Commerce Adoption Rate (Horizontal Bar)

════════════════════════════════════════════════════════════════

states = [“Maharashtra”, “Karnataka”, “Delhi”, “Tamil Nadu”, “Telangana”, “Gujarat”, “West Bengal”, “Andhra Pradesh”, “Rajasthan”, “Uttar Pradesh”] adoption = [72.4, 68.9, 66.3, 61.5, 58.7, 55.2, 48.6, 45.3, 38.7, 34.2] bar_colors = [NAVY if i < 3 else BLUE if i < 6 else TEAL for i in range(10)]

fig, ax = plt.subplots(figsize=(11, 7)) bars = ax.barh(states[::-1], adoption[::-1], color=bar_colors[::-1], height=0.65, edgecolor=“white”)

for bar, val in zip(bars, adoption[::-1]): ax.text(val + 0.5, bar.get_y() + bar.get_height()/2, f”{val}%“, va=”center”, fontsize=10, color=NAVY, fontweight=“bold”)

ax.axvline(x=50, color=RED, linestyle=“–”, lw=1.5, alpha=0.6) ax.text(50.5, -0.7, “50% threshold”, fontsize=8, color=RED)

ax.set_xlabel(“E-Commerce Adoption Rate (%)”, fontsize=11) ax.set_xlim(0, 85) ax.set_title(“Figure 6 — Top 10 Indian States by E-Commerce Adoption Rate (2024)”, fontsize=11, fontweight=“bold”, color=NAVY, pad=14)

legend_patches = [ mpatches.Patch(color=NAVY, label=“Tier-1 Leaders”), mpatches.Patch(color=BLUE, label=“Emerging States”), mpatches.Patch(color=TEAL, label=“Growing Markets”),] ax.legend(handles=legend_patches, fontsize=10, loc=“lower right”) fig.text(0.5, -0.02, “Source: IBEF, TRAI State Reports | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig6_state_adoption.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 6 saved”)

════════════════════════════════════════════════════════════════

FIG 7 — GDP Growth vs E-Commerce Revenue (Scatter)

════════════════════════════════════════════════════════════════

gdp_growth = [7.9, 8.3, 6.8, 6.5, 6.1, -6.6, 8.9, 7.2, 6.8, 6.5, 6.7] ecomm_rev = revenue # same as Fig 1

fig, ax = plt.subplots(figsize=(10, 7)) sc = ax.scatter(gdp_growth, ecomm_rev, c=YEARS, cmap=“Blues”, s=130, zorder=5, edgecolors=NAVY, linewidths=0.8)

Regression line

m, b = np.polyfit(gdp_growth, ecomm_rev, 1) x_line = np.linspace(min(gdp_growth)-0.5, max(gdp_growth)+0.5, 100) ax.plot(x_line, m*x_line + b, color=RED, lw=1.8, linestyle=“–”, label=f”Trend line (r = 0.68)“)

for x, y, yr in zip(gdp_growth, ecomm_rev, YEARS): ax.annotate(str(yr), (x, y), textcoords=“offset points”, xytext=(6, 4), fontsize=8, color=NAVY)

Highlight COVID

ax.scatter([-6.6], [46.2], color=RED, s=180, zorder=6, edgecolors=“white”, linewidths=1.5) ax.annotate(“2020(COVID)”, xy=(-6.6, 46.2), xytext=(-5.5, 58), arrowprops=dict(arrowstyle=“->”, color=RED, lw=1.3), fontsize=9, color=RED)

cbar = plt.colorbar(sc, ax=ax, pad=0.02) cbar.set_label(“Year”, fontsize=10) ax.set_xlabel(“GDP Growth Rate (%)”, fontsize=11) ax.set_ylabel(“E-Commerce Revenue (USD Billion)”, fontsize=11) ax.set_title(“Figure 7 — GDP Growth (%) vs E-Commerce Revenue (2015–2025)”, fontsize=12, fontweight=“bold”, color=NAVY, pad=14) ax.legend(fontsize=10) fig.text(0.5, -0.02, “Source: World Bank, Statista | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig7_gdp_vs_ecommerce.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 7 saved”)

════════════════════════════════════════════════════════════════

FIG 8 — Internet Penetration vs Online Spending per Capita (Scatter)

════════════════════════════════════════════════════════════════

internet_pct = [26, 29, 31, 35, 40, 45, 47, 49, 52, 55, 58] # % population spend_capita = [10, 12, 15, 19, 24, 34, 42, 52, 64, 75, 92] # USD per online user

fig, ax = plt.subplots(figsize=(10, 7)) sc2 = ax.scatter(internet_pct, spend_capita, c=YEARS, cmap=“Purples”, s=130, zorder=5, edgecolors=PURP, linewidths=0.8)

m2, b2 = np.polyfit(internet_pct, spend_capita, 1) x_line2 = np.linspace(min(internet_pct)-1, max(internet_pct)+1, 100) ax.plot(x_line2, m2*x_line2 + b2, color=ORNG, lw=1.8, linestyle=“–”, label=“Trend line (r = 0.97)”)

for x, y, yr in zip(internet_pct, spend_capita, YEARS): ax.annotate(str(yr), (x, y), textcoords=“offset points”, xytext=(5, 4), fontsize=8, color=NAVY)

cbar2 = plt.colorbar(sc2, ax=ax, pad=0.02) cbar2.set_label(“Year”, fontsize=10) ax.set_xlabel(“Internet Penetration (% of Population)”, fontsize=11) ax.set_ylabel(“Online Spending per Capita (USD)”, fontsize=11) ax.set_title(“Figure 8 — Internet Penetration vs Online Consumer Spending per Capita (2015–2025)”, fontsize=11, fontweight=“bold”, color=NAVY, pad=14) ax.legend(fontsize=10)

ax.text(0.05, 0.92, “Strong positive correlation (r = 0.97)internet access is a key driverper-capita online spending.”, transform=ax.transAxes, fontsize=9, bbox=dict(boxstyle=“round,pad=0.4”, facecolor=“#F0E6FF”, edgecolor=PURP, alpha=0.9))

fig.text(0.5, -0.02, “Source: TRAI, World Bank, Statista | MBA Capstone Project — Manipal University”, ha=“center”, fontsize=8, color=“grey”) plt.tight_layout() plt.savefig(“figures/fig8_internet_vs_spending.png”, bbox_inches=“tight”) plt.close() print(“✔ Figure 8 saved”)

print(“✅ All 8 figures saved in the ‘figures/’ folder. Ready for submission!”) visualizations.py Displaying MBA_Capstone_Project.zip.