.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/style/plot_depthshade.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_gallery_style_plot_depthshade.py: 3D depth shading ================ This example shows to to use depth shading in 3D plots to reduce the opacity (increase transparency) of vertices and edges that are further away from the viewer. This gives a better sense of depth but can be confusing in some cases, so there are style options to turn it off. .. GENERATED FROM PYTHON SOURCE LINES 9-24 .. code-block:: Python import igraph as ig import iplotx as ipx g = ig.Graph.Erdos_Renyi(15, m=20) layout = g.layout_fruchterman_reingold_3d() ipx.network( g, layout, vertex_alpha=0.9, figsize=(8, 8), ) .. image-sg:: /gallery/style/images/sphx_glr_plot_depthshade_001.png :alt: plot depthshade :srcset: /gallery/style/images/sphx_glr_plot_depthshade_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 25-34 Notice that depth shading is a 0-1 multiplier on top of the existing alpha value, so no vertex will have alpha (opacity) greater than 0.9 in this example, but vertices that are further back will have values below 0.9 (the minimum is usually 0.1). .. tip:: To get a better sense of depth shading, use Matplotlib with an interactive backend and rotate the plot using the mouse. You can turn off depth shading by setting ``depthshade=False`` for vertices and/or edges: .. GENERATED FROM PYTHON SOURCE LINES 34-44 .. code-block:: Python ipx.network( g, layout, vertex_alpha=0.9, figsize=(8, 8), vertex_depthshade=False, edge_depthshade=False, ) .. image-sg:: /gallery/style/images/sphx_glr_plot_depthshade_002.png :alt: plot depthshade :srcset: /gallery/style/images/sphx_glr_plot_depthshade_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 45-47 In this case all vertices have the same opacity (0.9) regardless of their depth, and all edges have an opacity of 1.0 (no transparency). .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.098 seconds) .. _sphx_glr_download_gallery_style_plot_depthshade.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_depthshade.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_depthshade.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_depthshade.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_