.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial/03_figures/exercises/b_lighting_mesh.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 or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorial_03_figures_exercises_b_lighting_mesh.py: Lighting Properties ~~~~~~~~~~~~~~~~~~~ Control aspects of the rendered mesh's lighting such as Ambient, Diffuse, and Specular. These options only work if the ``lighting`` argument to ``add_mesh`` is ``True`` (it's ``True`` by default). You can turn off all lighting for the given mesh by passing ``lighting=False`` to ``add_mesh``. See the ``add_mesh`` docs for lighting options: https://docs.pyvista.org/api/plotting/_autosummary/pyvista.Plotter.add_mesh.html .. GENERATED FROM PYTHON SOURCE LINES 15-23 .. code-block:: Python import pyvista as pv from pyvista import examples mesh = examples.download_st_helens().warp_by_scalar() cpos = [(575848.0, 5128459.0, 22289.0), (562835.0, 5114981.5, 2294.5), (-0.5, -0.5, 0.7)] .. GENERATED FROM PYTHON SOURCE LINES 25-26 First, let's take a look at the mesh with default lighting conditions .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: Python mesh.plot(cpos=cpos, show_scalar_bar=False) .. GENERATED FROM PYTHON SOURCE LINES 29-30 What about with no lighting? .. GENERATED FROM PYTHON SOURCE LINES 30-32 .. code-block:: Python mesh.plot(..., cpos=cpos, show_scalar_bar=False) .. GENERATED FROM PYTHON SOURCE LINES 33-36 Demonstration of the specular property Feel free to adjust the specular value in the ``s`` variable. .. GENERATED FROM PYTHON SOURCE LINES 36-51 .. code-block:: Python p = pv.Plotter(shape=(1, 2), window_size=[1500, 500]) p.subplot(0, 0) p.add_mesh(mesh, show_scalar_bar=False) p.add_text('No Specular') p.subplot(0, 1) specular = ... p.add_mesh(mesh, ..., show_scalar_bar=False) p.add_text(f'Specular of {specular}') p.link_views() p.view_isometric() p.show(cpos=cpos) .. GENERATED FROM PYTHON SOURCE LINES 52-53 Specular power (feel free to adjust) .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python mesh.plot(..., cpos=cpos, show_scalar_bar=False) .. GENERATED FROM PYTHON SOURCE LINES 56-58 Demonstration of all diffuse, specular, and ambient in use together (feel free to adjust) .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: Python mesh.plot(..., cpos=cpos, show_scalar_bar=False) .. GENERATED FROM PYTHON SOURCE LINES 61-63 For detailed control over lighting conditions in general see the `lighting examples `_ .. GENERATED FROM PYTHON SOURCE LINES 65-72 .. raw:: html
Open In Colab
.. _sphx_glr_download_tutorial_03_figures_exercises_b_lighting_mesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/pyvista/pyvista-tutorial/gh-pages?urlpath=lab/tree/notebooks/tutorial/03_figures/exercises/b_lighting_mesh.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: b_lighting_mesh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: b_lighting_mesh.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_