.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_plot/plot_aspect_ratios.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_aspect_ratios.py: Aspect ratios ============= .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) By default, filled contour plots try to retain the true mesh proportions. If the meshes aspect ratio lies outside of predefined limits (setup.min_ax_aspect, setup.max_ax_aspect) the axes get compressed to stay inside the given limits. The following examples shall illustrate this behaviour. .. GENERATED FROM PYTHON SOURCE LINES 15-25 .. code-block:: Python import numpy as np import pyvista as pv import ogstools as ogs print(f"{ogs.plot.setup.min_ax_aspect=}") print(f"{ogs.plot.setup.max_ax_aspect=}") .. rst-class:: sphx-glr-script-out .. code-block:: none ogs.plot.setup.min_ax_aspect=0.5 ogs.plot.setup.max_ax_aspect=2.0 .. GENERATED FROM PYTHON SOURCE LINES 43-45 The following fits inside the defined limits and gets displayed with true proportions. .. GENERATED FROM PYTHON SOURCE LINES 47-48 .. code-block:: Python fig = ogs.plot.contourf(custom_mesh(np.pi * 2, np.pi), "example") .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_001.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 49-51 This one would be too wide and thus and gets compressed to fit the maximum aspect ratio. .. GENERATED FROM PYTHON SOURCE LINES 53-54 .. code-block:: Python fig = ogs.plot.contourf(custom_mesh(np.pi * 4, np.pi), "example") .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_002.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 55-57 When plotting multiple meshes together, this applies to each subplot. So here each subplot has true proportions again since each one fits the limits. .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python fig = ogs.plot.contourf( [custom_mesh(np.pi * 2, np.pi), custom_mesh(np.pi * 2, np.pi)], "example" ) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_003.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 63-65 The following figure would be to tall and is clipped to the minimum aspect ratio. .. GENERATED FROM PYTHON SOURCE LINES 67-68 .. code-block:: Python fig = ogs.plot.contourf(custom_mesh(np.pi, np.pi * 3), "example") .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_004.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 69-70 The same is true here: .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: Python fig = ogs.plot.contourf( [custom_mesh(np.pi, np.pi * 3), custom_mesh(np.pi, np.pi * 3)], "example" ) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_005.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 77-80 You can enforce true proportions regardless of the resulting figures dimensions, by setting the limiting values to None. In this case we get a very wide figure. .. GENERATED FROM PYTHON SOURCE LINES 82-86 .. code-block:: Python ogs.plot.setup.min_ax_aspect = None ogs.plot.setup.max_ax_aspect = None fig = ogs.plot.contourf(custom_mesh(np.pi * 3, np.pi), "example") .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_006.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 87-88 And in this case we get a very tall figure. .. GENERATED FROM PYTHON SOURCE LINES 90-91 .. code-block:: Python fig = ogs.plot.contourf(custom_mesh(np.pi, np.pi * 3), "example") .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_007.png :alt: plot aspect ratios :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_aspect_ratios_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.210 seconds) .. _sphx_glr_download_auto_examples_howto_plot_plot_aspect_ratios.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_aspect_ratios.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_aspect_ratios.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_aspect_ratios.zip `