{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Data Visualization with Python\n",
        "\n**Opening question:** What should a figure reveal that a table or coefficient cannot show as clearly?\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "series = pd.Series([1.2, 1.4, 1.3, 1.6], index=pd.date_range(\"2026-01-01\", periods=4, freq=\"MS\"))\n",
        "fig, ax = plt.subplots()\n",
        "ax.plot(series.index, series.values, marker=\"o\")\n",
        "ax.set(title=\"Illustrative Monthly Index\", xlabel=\"Month\", ylabel=\"Index points\")\n",
        "fig.tight_layout()\n",
        "plt.close(fig)\n",
        "print(len(series))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Interpretation check:** Interpretation. The code creates a reusable figure object and labels both the time dimension and the unit.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "rng = np.random.default_rng(12)\n",
        "values = rng.standard_t(df=5, size=1_000)\n",
        "fig, ax = plt.subplots()\n",
        "ax.hist(values, bins=35, density=True)\n",
        "ax.set(title=\"Heavy-tailed simulated observations\", xlabel=\"Value\", ylabel=\"Density\")\n",
        "plt.close(fig)\n",
        "print(round(values.std(), 3))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Interpretation check:** Interpretation. The histogram reveals tails and concentration that a standard deviation alone cannot convey.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "fig, ax = plt.subplots()\n",
        "ax.plot(series.index, series.values, marker=\"o\")\n",
        "ax.set(title=\"Illustrative Monthly Index\", xlabel=\"Month\", ylabel=\"Index points\")\n",
        "fig.tight_layout()\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Verified source output\n",
        "\n",
        "```text\n4\n```\n\n```text\n1.263\n```\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3"
    },
    "ceteris_lab": {
      "course_slug": "fundamentals-python-econometrics",
      "source_derived": true,
      "course_title": "Fundamentals of Python for Financial Econometrics",
      "chapter": 12,
      "source_origin": "source-derived"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
