.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\06-plotting\00-basic_plotting.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_examples_06-plotting_00-basic_plotting.py: .. _basic_plotting: Review of available plotting commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This example lists the different plotting commands available, shown with the arguments available. .. GENERATED FROM PYTHON SOURCE LINES 11-94 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_001.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_002.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_003.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_004.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_005.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_005.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_006.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_006.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_007.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_007.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_008.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_008.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_009.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_009.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_010.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_010.png :class: sphx-glr-multi-img * .. image-sg:: /examples/06-plotting/images/sphx_glr_00-basic_plotting_011.png :alt: 00 basic plotting :srcset: /examples/06-plotting/images/sphx_glr_00-basic_plotting_011.png :class: sphx-glr-multi-img .. code-block:: Python from ansys.dpf import core as dpf from ansys.dpf.core import examples # Plot the bare mesh of a model model = dpf.Model(examples.find_multishells_rst()) model.plot(color="w", show_edges=True, title="Model", text="Model plot") # # Additional PyVista kwargs are supported, such as: model.plot( off_screen=True, notebook=False, screenshot="model_plot.png", title="Model", text="Model plot off", ) # Notes: # - To make screenshots, use "screenshot" as well as "notebook=False" if on a Jupyter notebook. # - The "off_screen" keyword only works when "notebook=False" to prevent the GUI from appearing. # Plot a field on its supporting mesh (field location must be Elemental or Nodal) stress = model.results.stress() stress.inputs.requested_location.connect(dpf.locations.nodal) fc = stress.outputs.fields_container() field = fc[0] field.plot(notebook=False, shell_layers=None, show_axes=True, title="Field", text="Field plot") # # Additional PyVista kwargs are supported, such as: field.plot( off_screen=True, notebook=False, screenshot="field_plot.png", title="Field", text="Field plot off", ) # # # Alternatively one can plot the MeshedRegion associated to the model mesh = model.metadata.meshed_region mesh.plot( field_or_fields_container=None, shell_layers=None, show_axes=True, title="Mesh fc None", text="Mesh plot", ) # Additional PyVista kwargs are supported, such as: mesh.plot( off_screen=True, notebook=False, screenshot="mesh_plot.png", title="Mesh", text="Mesh plot off", ) # A fields_container or a specific field can be given to plot on the mesh. mesh.plot( field_or_fields_container=fc, title="Mesh with fields container", text="Mesh fc plot", ) mesh.plot(field_or_fields_container=field, title="Mesh with field", text="Mesh field plot") # ############################################################################################## # # This next section requires a Premium context to be active du to the ``split_mesh`` operator. # # Comment this last part to run the example as Entry. # One can also plot a MeshesContainer. Here our mesh is split by material. split_mesh_op = dpf.Operator("split_mesh") split_mesh_op.connect(7, mesh) split_mesh_op.connect(13, "mat") meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container) meshes_cont.plot(title='Meshes Container', text='Meshes Container plot') # A fields_container can be given as input, with results on each part of our split mesh. disp_op = dpf.Operator("U") disp_op.connect(7, meshes_cont) ds = dpf.DataSources(examples.find_multishells_rst()) disp_op.connect(4, ds) disp_fc = disp_op.outputs.fields_container() meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot') # Additional PyVista kwargs are supported, such as: meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png', title='Meshes Container', text='Meshes Container plot') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 13.459 seconds) .. _sphx_glr_download_examples_06-plotting_00-basic_plotting.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00-basic_plotting.ipynb <00-basic_plotting.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00-basic_plotting.py <00-basic_plotting.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_