.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_plot/plot_shared_axes.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_howto_plot_plot_shared_axes.py: Shared axes =========== .. sectionauthor:: Feliks Kiszkurno (Helmholtz Centre for Environmental Research GmbH - UFZ) In this example we show how to create filled contourplots on a figure with subplots having shared axes. .. GENERATED FROM PYTHON SOURCE LINES 12-22 .. code-block:: Python import matplotlib.pyplot as plt import ogstools as ot from ogstools import examples meshseries = examples.load_meshseries_THM_2D_PVD().scale(spatial=("m", "km")) mesh_0 = meshseries.mesh(0) mesh_1 = meshseries.mesh(1) temperature = ot.variables.temperature .. GENERATED FROM PYTHON SOURCE LINES 23-26 If you pass multiple meshes to :py:func:`ogstools.plot.contourf` by default both x and y axes will shared. Thus, only the outer axes get axes labels and tick label. .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: Python fig = ot.plot.contourf([mesh_0, mesh_1], temperature) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_shared_axes_001.png :alt: plot shared axes :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_shared_axes_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 30-32 On user defined figure and axis the axis belonging to specific subplot has to be passed. .. GENERATED FROM PYTHON SOURCE LINES 32-41 .. code-block:: Python fig, axs = plt.subplots(2, 2, figsize=(40, 17), sharex=True, sharey=True) diff_a = mesh_0.difference(mesh_1, temperature) diff_b = mesh_1.difference(mesh_0, temperature) ot.plot.contourf(mesh_0, temperature, fig=fig, ax=axs[0][0]) ot.plot.contourf(mesh_1, temperature, fig=fig, ax=axs[1][0]) ot.plot.contourf(diff_a, temperature, fig=fig, ax=axs[0][1]) ot.plot.contourf(diff_b, temperature, fig=fig, ax=axs[1][1]) fig.tight_layout() .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_shared_axes_002.png :alt: plot shared axes :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_shared_axes_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.120 seconds) .. _sphx_glr_download_auto_examples_howto_plot_plot_shared_axes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_shared_axes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_shared_axes.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_shared_axes.zip `