{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Figure with several subplots (a.k.a. axes)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:30:16.419246Z", "iopub.status.busy": "2025-01-13T11:30:16.418723Z", "iopub.status.idle": "2025-01-13T11:30:16.944143Z", "shell.execute_reply": "2025-01-13T11:30:16.943679Z" } }, "outputs": [], "source": [ "%matplotlib inline\n", "# for figures in notebook\n", "\n", "# import & initialize epygram\n", "import epygram\n", "epygram.init_env()\n", "\n", "import os\n", "INPUTS_DIR = os.path.join('..', 'inputs')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:30:16.946121Z", "iopub.status.busy": "2025-01-13T11:30:16.945887Z", "iopub.status.idle": "2025-01-13T11:30:17.062763Z", "shell.execute_reply": "2025-01-13T11:30:17.062275Z" } }, "outputs": [], "source": [ "r = epygram.open(os.path.join(INPUTS_DIR, 'ic.full-surfex.corsica-02km50.fa'), 'r')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:30:17.064705Z", "iopub.status.busy": "2025-01-13T11:30:17.064511Z", "iopub.status.idle": "2025-01-13T11:30:17.110392Z", "shell.execute_reply": "2025-01-13T11:30:17.109965Z" } }, "outputs": [], "source": [ "tg = r.readfield('X001TG1')\n", "ts = r.readfield('SFX.SST')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-01-13T11:30:17.112001Z", "iopub.status.busy": "2025-01-13T11:30:17.111837Z", "iopub.status.idle": "2025-01-13T11:30:18.225272Z", "shell.execute_reply": "2025-01-13T11:30:18.224872Z" } }, "outputs": [], "source": [ "from matplotlib.pyplot import figure\n", "fig = figure(figsize=(10,5))\n", "# in this case the projection needs to be specified early on\n", "from cartopy import crs as ccrs\n", "ax1 = fig.add_subplot(1, 2, 1, projection=tg.geometry.default_cartopy_CRS())\n", "ax2 = fig.add_subplot(1, 2, 2, projection=ccrs.NorthPolarStereo())\n", "# then plot\n", "tg.cartoplot(fig=fig, ax=ax1)\n", "ts.cartoplot(fig=fig, ax=ax2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.10.12" } }, "nbformat": 4, "nbformat_minor": 4 }