{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Make our Logo!\n", "\n", "The logo combines a number of fun **pyam** features, including\n", "\n", "- line plots\n", "- filling data between lines\n", "- adding ranges of final-year data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "plt.style.use(\"seaborn-v0_8-deep\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "\n", "def func(x, factor):\n", " return np.sin(x) + factor * x\n", "\n", "\n", "x = np.linspace(0, 4, 100)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import itertools\n", "\n", "import pandas as pd\n", "\n", "from pyam import IAMC_IDX, IamDataFrame\n", "\n", "combinations = itertools.product([\"m1\", \"m2\", \"m3\", \"m4\"], [\"s1\", \"s2\", \"s3\"])\n", "data = [\n", " [m, s] + [\"r\", \"v\", \"u\"] + list(func(x, 0.5 + 0.1 * i))\n", " for i, (m, s) in enumerate(combinations)\n", "]\n", "df = IamDataFrame(pd.DataFrame(data, columns=IAMC_IDX + list(range(len(x)))))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots()\n", "df.filter(scenario=\"s2\").plot(ax=ax, color=\"model\", legend=False, title=False)\n", "df.filter(scenario=\"s2\", keep=False).plot(\n", " ax=ax, linewidth=0.5, color=\"model\", legend=False, title=False\n", ")\n", "df.plot(\n", " ax=ax,\n", " alpha=0,\n", " color=\"model\",\n", " fill_between=True,\n", " final_ranges=dict(linewidth=4),\n", " legend=False,\n", " title=False,\n", ")\n", "plt.axis(\"off\")\n", "plt.tight_layout()\n", "fig.savefig(\"logo.pdf\", bbox_inches=\"tight\", transparent=True, pad_inches=0)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12.2" } }, "nbformat": 4, "nbformat_minor": 2 }