.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/jupyter_plotting_demo.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_jupyter_plotting_demo.py: Jupyter notebook plotting ========================== This example demonstrates the Jupyter notebook support for deck.plot(). The plotting system automatically detects Jupyter environments and adjusts the PyVista backend accordingly. When running in a Jupyter notebook, PyDyna automatically uses the 'static' backend for screenshots, or you can explicitly choose 'server' for interactive widgets. Outside Jupyter, it uses the standard PyVista behavior. See GitHub issue #601 for details. .. GENERATED FROM PYTHON SOURCE LINES 39-42 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Import required packages. .. GENERATED FROM PYTHON SOURCE LINES 42-47 .. code-block:: Python import pandas as pd from ansys.dyna.core import Deck, keywords as kwd .. GENERATED FROM PYTHON SOURCE LINES 48-51 Create a simple deck ~~~~~~~~~~~~~~~~~~~~ Create a deck with 8 nodes forming a hex element. .. GENERATED FROM PYTHON SOURCE LINES 51-82 .. code-block:: Python deck = Deck() # Create 8 nodes for a hex element node_kwd = kwd.Node() nodes_data = pd.DataFrame( { "nid": [1, 2, 3, 4, 5, 6, 7, 8], "x": [0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], "y": [0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0], "z": [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0], } ) node_kwd.nodes = nodes_data deck.append(node_kwd) # Create a solid element solid_kwd = kwd.ElementSolid() elements_data = pd.DataFrame( {"eid": [1], "pid": [1], "n1": [1], "n2": [2], "n3": [3], "n4": [4], "n5": [5], "n6": [6], "n7": [7], "n8": [8]} ) solid_kwd.elements = elements_data deck.append(solid_kwd) # Add a section section_kwd = kwd.SectionSolid(secid=1) section_kwd.elform = 1 deck.append(section_kwd) print(f"Deck created with {len(deck)} keywords") .. rst-class:: sphx-glr-script-out .. code-block:: none Deck created with 3 keywords .. GENERATED FROM PYTHON SOURCE LINES 83-87 Plot with auto-detection ~~~~~~~~~~~~~~~~~~~~~~~~~ In Jupyter notebooks, this automatically uses the 'static' backend. Outside Jupyter, it uses the default PyVista behavior. .. GENERATED FROM PYTHON SOURCE LINES 87-90 .. code-block:: Python # deck.plot() .. GENERATED FROM PYTHON SOURCE LINES 91-98 Plot with explicit backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can explicitly specify the backend: - 'static': screenshot (fast, works everywhere) - 'server': interactive widget (requires jupyter-server-proxy) - 'trame': trame-based viewer (experimental) - None: disable Jupyter handling, use standard PyVista .. GENERATED FROM PYTHON SOURCE LINES 98-101 .. code-block:: Python # deck.plot(jupyter_backend='static') .. GENERATED FROM PYTHON SOURCE LINES 102-105 Plot with custom styling ~~~~~~~~~~~~~~~~~~~~~~~~~ All standard PyVista plot options work with Jupyter: .. GENERATED FROM PYTHON SOURCE LINES 105-107 .. code-block:: Python # deck.plot(jupyter_backend='static', color='lightblue', show_edges=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.016 seconds) .. _sphx_glr_download_examples_jupyter_plotting_demo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: jupyter_plotting_demo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: jupyter_plotting_demo.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: jupyter_plotting_demo.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_