.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/example_plot.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_example_plot.py: .. _example_plot: =================================== Examples of the use of plot in slam =================================== .. GENERATED FROM PYTHON SOURCE LINES 8-15 .. code-block:: Python # Authors: # Guillaume Auzias # License: MIT # sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 16-17 importation of slam modules .. GENERATED FROM PYTHON SOURCE LINES 17-20 .. code-block:: Python import slam.io as sio import slam.plot as splt .. GENERATED FROM PYTHON SOURCE LINES 21-22 Load a mesh .. GENERATED FROM PYTHON SOURCE LINES 22-34 .. code-block:: Python mesh_file = "../examples/data/example_mesh.gii" mesh = sio.load_mesh(mesh_file) mesh_data = {} mesh_data['vertices'] = mesh.vertices mesh_data['faces'] = mesh.faces mesh_data['title'] = 'Simplest plot' fig1 = splt.plot_mesh( mesh_data=mesh_data) fig1.show() fig1 .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 35-39 To save the figure as png on the disc fig1.write_image("example_figure.png", width=1600, height=900) save the figure as an interactive HTML file fig1.write_html(SAVE_DIR) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Load a texture .. GENERATED FROM PYTHON SOURCE LINES 42-73 .. code-block:: Python tex = sio.load_texture("../examples/data/example_dpf.gii") # To tune the visualization of the texture, use the "intensity_data" dict: # "intensity": intensity_data["values"], # "intensitymode": intensity_data.get("mode", "cell"), # "colorscale": display_settings.get("colorscale", "Turbo"), # "cmin": intensity_data.get("cmin", None), # "cmax": intensity_data.get("cmax", None), # The "display_settings" dict can also be used: # "colorbar": { # "title": display_settings.get("colorbar_label", ""), # "colorbar_tickvals": display_settings.get("tickvals", None), # "colorbar_ticktext": display_settings.get("ticktext", None), mesh_data = {} mesh_data['vertices'] = mesh.vertices mesh_data['faces'] = mesh.faces mesh_data['title'] = 'Plot a texture on a mesh' intensity_data = {} intensity_data['values'] = tex.darray[0] intensity_data["mode"] = "vertex" display_settings = {} display_settings['colorbar_label'] = 'DPF' fig2 = splt.plot_mesh( mesh_data=mesh_data, intensity_data=intensity_data, display_settings=display_settings) fig2.show() fig2 .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 74-75 Complete example with all modifiable parameters .. GENERATED FROM PYTHON SOURCE LINES 75-130 .. code-block:: Python mesh_data = { "vertices": mesh.vertices, "faces": mesh.faces, "title": "the title", # figure title, default is None } intensity_data = { "values": tex.darray[0], "mode": "vertex", # default is "cell" "cmin": 0, # default is automatic value "cmax": 1, } display_settings = { "colorscale": "RdBu", # color scale, default is Turbo "colorbar_label": "name of the texture", # colorbar label, default is None "template": "plotly_dark", # default is blank theme without axes "tickvals": [ 0, 0.25, 0.5, 0.75, 1, ], # default is None, sets exact tick positions on the colorbar "ticktext": [ "0%", "25%", "50%", "75%", "100%", ], # default is None, customizes tick labels on the colorbar } fig3 = splt.plot_mesh( mesh_data, intensity_data, display_settings, caption=True, # snapshot, default is None ) # add an additional trace # example: display vertex index on hover and customize vertex color and size # over the mesh hover_text = [f"vertex {i}" for i in range(len(mesh.vertices))] trace_hover = splt.create_hover_trace( mesh.vertices, text=hover_text, marker={"size": 4, "color": "blue"}, ) fig3.add_trace(trace_hover, row=1, col=1) fig3.add_trace(trace_hover, row=1, col=2) fig3.show() fig3 .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.408 seconds) .. _sphx_glr_download_auto_examples_example_plot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_plot.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_plot.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_plot.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_