.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshplotlib/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_meshplotlib_plot_aspect_ratios.py: Aspect ratios ============= .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) By default plots with meshplotlib 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-26 .. code-block:: Python import numpy as np import pyvista as pv from ogstools.meshplotlib import plot, setup setup.reset() print(f"{setup.min_ax_aspect=}") print(f"{setup.max_ax_aspect=}") .. rst-class:: sphx-glr-script-out .. code-block:: none setup.min_ax_aspect=0.5 setup.max_ax_aspect=2.0 .. GENERATED FROM PYTHON SOURCE LINES 44-46 The following fits inside the defined limits and gets displayed with true proportions. .. GENERATED FROM PYTHON SOURCE LINES 48-49 .. code-block:: Python fig = plot(custom_mesh(np.pi * 2, np.pi), "example") .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_001.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 50-52 This one would be too wide and thus and gets compressed to fit the maximum aspect ratio. .. GENERATED FROM PYTHON SOURCE LINES 54-55 .. code-block:: Python fig = plot(custom_mesh(np.pi * 4, np.pi), "example") .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_002.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-58 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 60-63 .. code-block:: Python fig = plot( [custom_mesh(np.pi * 2, np.pi), custom_mesh(np.pi * 2, np.pi)], "example" ) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_003.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 64-66 The following figure would be to tall and is clipped to the minimum aspect ratio. .. GENERATED FROM PYTHON SOURCE LINES 68-69 .. code-block:: Python fig = plot(custom_mesh(np.pi, np.pi * 3), "example") .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_004.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 70-71 The same is true here: .. GENERATED FROM PYTHON SOURCE LINES 73-77 .. code-block:: Python fig = plot( [custom_mesh(np.pi, np.pi * 3), custom_mesh(np.pi, np.pi * 3)], "example" ) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_005.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 78-81 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 83-87 .. code-block:: Python setup.min_ax_aspect = None setup.max_ax_aspect = None fig = plot(custom_mesh(np.pi * 3, np.pi), "example") .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_006.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 88-89 And in this case we get a very tall figure. .. GENERATED FROM PYTHON SOURCE LINES 91-92 .. code-block:: Python fig = plot(custom_mesh(np.pi, np.pi * 3), "example") .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_aspect_ratios_007.png :alt: plot aspect ratios :srcset: /auto_examples/howto_meshplotlib/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.906 seconds) .. _sphx_glr_download_auto_examples_howto_meshplotlib_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 `