{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# XKCD\n\nShows how to create an xkcd-like plot.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "with plt.xkcd():\n    # Based on \"Stove Ownership\" from XKCD by Randall Munroe\n    # https://xkcd.com/418/\n\n    fig = plt.figure()\n    ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))\n    ax.spines[['top', 'right']].set_visible(False)\n    ax.set_xticks([])\n    ax.set_yticks([])\n    ax.set_ylim(-30, 10)\n\n    data = np.ones(100)\n    data[70:] -= np.arange(30)\n\n    ax.annotate(\n        'THE DAY I REALIZED\\nI COULD COOK BACON\\nWHENEVER I WANTED',\n        xy=(70, 1), arrowprops=dict(arrowstyle='->'), xytext=(15, -10))\n\n    ax.plot(data)\n\n    ax.set_xlabel('time')\n    ax.set_ylabel('my overall health')\n    fig.text(\n        0.5, 0.05,\n        '\"Stove Ownership\" from xkcd by Randall Munroe',\n        ha='center')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "with plt.xkcd():\n    # Based on \"The Data So Far\" from XKCD by Randall Munroe\n    # https://xkcd.com/373/\n\n    fig = plt.figure()\n    ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))\n    ax.bar([0, 1], [0, 100], 0.25)\n    ax.spines[['top', 'right']].set_visible(False)\n    ax.xaxis.set_ticks_position('bottom')\n    ax.set_xticks([0, 1])\n    ax.set_xticklabels(['CONFIRMED BY\\nEXPERIMENT', 'REFUTED BY\\nEXPERIMENT'])\n    ax.set_xlim(-0.5, 1.5)\n    ax.set_yticks([])\n    ax.set_ylim(0, 110)\n\n    ax.set_title(\"CLAIMS OF SUPERNATURAL POWERS\")\n\n    fig.text(\n        0.5, 0.05,\n        '\"The Data So Far\" from xkcd by Randall Munroe',\n        ha='center')\n\nplt.show()\n\n#"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n\n   plot-type: line\n   plot-type: bar\n   purpose: fun\n\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}