.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_plot/plot_contourf_2d.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_contourf_2d.py: Visualizing 2D model data ========================= .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) To demonstrate the creation of filled contour plots we load a 2D THM meshseries example. In the ``plot.setup`` we can provide a dictionary to map names to material ids. Other plot configurations are also available, see: :py:obj:`ogstools.plot.plot_setup.PlotSetup`. Some of these options are also available as keyword arguments in the function call. Please see :py:obj:`ogstools.plot.contourplots.contourf` for more information. .. GENERATED FROM PYTHON SOURCE LINES 16-22 .. code-block:: Python import ogstools as ogs from ogstools import examples ogs.plot.setup.material_names = {i + 1: f"Layer {i+1}" for i in range(26)} mesh = examples.load_meshseries_THM_2D_PVD().mesh(1) .. GENERATED FROM PYTHON SOURCE LINES 23-29 To read your own data as a mesh series you can do: .. code-block:: python mesh_series = ogs.MeshSeries("filepath/filename_pvd_or_xdmf") .. GENERATED FROM PYTHON SOURCE LINES 31-32 the setup, this will automatically show the element edges. .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.material_id) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_001.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-38 Now, let's plot the temperature field (point_data) at the first timestep. The default temperature variable from the `variables` reads the temperature data as Kelvin and converts them to degrees Celsius. .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.temperature, show_max=True) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_002.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-44 We can also plot components of vector variables: .. GENERATED FROM PYTHON SOURCE LINES 46-50 .. code-block:: Python fig = mesh.plot_contourf( ogs.variables.displacement[0], show_min=True, show_max=True ) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_003.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: Python fig = mesh.plot_contourf( ogs.variables.displacement[1], show_max=True, show_edges=True ) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_004.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-57 This example has hydraulically deactivated subdomains: .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.pressure.get_mask(), fontsize=40) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_005.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 62-63 Let's plot the fluid velocity field. .. GENERATED FROM PYTHON SOURCE LINES 65-67 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.velocity, show_region_bounds=False) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_006.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 68-69 Let's plot it again, this time log-scaled. .. GENERATED FROM PYTHON SOURCE LINES 71-72 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.velocity, log_scaled=True, vmin=-8) .. image-sg:: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_007.png :alt: plot contourf 2d :srcset: /auto_examples/howto_plot/images/sphx_glr_plot_contourf_2d_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.343 seconds) .. _sphx_glr_download_auto_examples_howto_plot_plot_contourf_2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_contourf_2d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_contourf_2d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_contourf_2d.zip `