Skip to content

Commit

Permalink
multiple plots
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Jan 8, 2024
1 parent ab930a8 commit 7336250
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions notebooks/wp5/urban_heat_islands.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
"metadata": {},
"outputs": [],
"source": [
"def compare_albedo_and_temperature(da_albedo, da_temperature, freq):\n",
"def compare_albedo_and_temperature(da_albedo, da_temperature, freq, ax1):\n",
" # Resample\n",
" da_albedo = da_albedo.resample(time=freq).mean()\n",
" da_temperature = da_temperature.resample(forecast_reference_time=freq).mean()\n",
Expand All @@ -259,7 +259,6 @@
" da_temperature = da_temperature - 273.15\n",
" da_temperature.attrs[\"units\"] = \"°C\"\n",
"\n",
" fig, ax1 = plt.subplots()\n",
" # Plot temperature\n",
" color = \"red\"\n",
" ax1.bar(\n",
Expand Down Expand Up @@ -296,8 +295,7 @@
" )\n",
" ],\n",
" )\n",
" fig.autofmt_xdate(rotation=45)\n",
" return fig, (ax1, ax2)\n",
" return (ax1, ax2)\n",
"\n",
"\n",
"def plot_maps(da, lon_slice=None, lat_slice=None, area=area, **kwargs):\n",
Expand Down Expand Up @@ -392,15 +390,17 @@
"metadata": {},
"outputs": [],
"source": [
"for freq in (\"1MS\", \"QS-DEC\"):\n",
" for satellite, ds_albedo in albedo_timeseries_zoom.items():\n",
"fig, axs = plt.subplots(2, 2, sharex=False, figsize=(10, 10))\n",
"axs = iter(axs.flatten())\n",
"for satellite, ds_albedo in albedo_timeseries_zoom.items():\n",
" for freq in (\"1MS\", \"QS-DEC\"):\n",
" ax = next(axs)\n",
" da_albedo = ds_albedo[\"AL_BH_BB\"]\n",
" da_temperature = temperature_timeseries_zoom[satellite][\"t2m\"]\n",
" fig, (ax1, ax2) = compare_albedo_and_temperature(\n",
" da_albedo, da_temperature, freq\n",
" )\n",
" fig.suptitle(f\"{satellite=} {freq=}\")\n",
" plt.show()"
" ax1, ax2 = compare_albedo_and_temperature(da_albedo, da_temperature, freq, ax)\n",
" ax.set_title(f\"{satellite=} {freq=}\")\n",
" fig.tight_layout()\n",
" fig.autofmt_xdate(rotation=45)"
]
},
{
Expand Down

0 comments on commit 7336250

Please sign in to comment.