.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_multiple_vars.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_multiple_vars.py: ======================================================= Plot multiple variables ======================================================= This example shows how to plot multiple variables from a GenieModel object. I use a modern model run as an example and plot the surface temperature, PO4, Fe, and O2. The following features are particularly demonstrated: #. Customizing the plot projection with cartopy #. Plotting multiple variables in one figure #. Controlling the elements in cgeniepy.GriddedDataVis object #. Using CommunityPalette to get a pretty color palette .. GENERATED FROM PYTHON SOURCE LINES 18-39 .. image-sg:: /auto_examples/images/sphx_glr_plot_multiple_vars_001.png :alt: plot multiple vars :srcset: /auto_examples/images/sphx_glr_plot_multiple_vars_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/stable/lib/python3.12/site-packages/cgeniepy/model.py:58: UserWarning: No gemflag is provided, use default gemflags: [biogem] warnings.warn("No gemflag is provided, use default gemflags: [biogem]") | .. code-block:: Python import matplotlib.pyplot as plt import cartopy.crs as ccrs import cgeniepy from cgeniepy.plot import CommunityPalette fig, axs = plt.subplots(2, 2, figsize=(10, 8), subplot_kw={'projection': ccrs.PlateCarree()}) pi_model = cgeniepy.sample_model() variable = ['ocn_sur_temp', 'bio_fexport_POC', 'ocn_sur_PO4','ocn_sur_O2'] cmap = ['r_terrain', 'tol_rainbow', 'parula','ODV'] for i in range(4): data = pi_model.get_var(variable[i]).isel(time=-1).to_GriddedDataVis() data.aes_dict['pcolormesh_kwargs']['cmap'] = CommunityPalette(cmap[i]).colormap data.aes_dict['contourf_kwargs']['cmap'] = CommunityPalette(cmap[i]).colormap data.aes_dict['facecolor_kwargs']['c'] = 'white' data.plot(ax=axs.flatten()[i],colorbar=True, outline=True, gridline=True, contourf=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.503 seconds) .. _sphx_glr_download_auto_examples_plot_multiple_vars.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_multiple_vars.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_multiple_vars.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_multiple_vars.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_