:orphan:

Scene
=====

More example scripts are available in the VisPy repository's
`example scripts directory <https://github.com/vispy/vispy/tree/main/examples>`_.



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of borders and background colors">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_background_borders_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_background_borders.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Demonstration of borders and background colors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple use of SceneCanvas and ColorBarWidget to display a ColorBar">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_colorbar_widget_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_colorbar_widget.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Display a ColorBar</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Changing Line Colors">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_colored_line_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_colored_line.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Changing Line Colors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate the use of the vispy console.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_console_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_console.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vispy Console</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to visualise a NetworkX graph using a VisPy Graph.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_graph_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_graph.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Visualize NetworkX Graph</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of InfiniteLine visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_infinite_line_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_infinite_line.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw an InfiniteLine</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Compare instanced and GL_POINTS rendering methods for Markers visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_instanced_markers_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_instanced_markers.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Markers with Instanced Rendering</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="# this example is based on the tutorial: T01_basic_visual.py">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_instanced_quad_visual_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_instanced_quad_visual.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Visual for instanced rendering of a colored quad</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple use of SceneCanvas to display an Isocurve visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_isocurve_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_isocurve.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Display an Isocurve</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates isocurve for triangular mesh with vertex data.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_isocurve_for_trisurface_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_isocurve_for_trisurface.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Isocurve for Triangular Mesh</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates isocurve for triangular mesh with vertex data and a qt interface.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_isocurve_for_trisurface_qt_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_isocurve_for_trisurface_qt.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Isocurve for Triangular Mesh with Qt Interface</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Show use of SceneCanvas to display and update Image and Isocurve visuals using ViewBox visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_isocurve_updates_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_isocurve_updates.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Update Image and Isocurve Visuals</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates the use of the Isosurface visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_isosurface_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_isosurface.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Isosurface Visual</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate the use of lasso selection.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_lasso_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_lasso.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vispy Lasso</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple demonstration of SceneCanvas containing a single line entity as its entire scenegraph.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_line_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_line.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw a Line</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of animated Line visual.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_line_update_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_line_update.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Animated Line Visual</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of LinearRegion visual. Allows drawing of infinite horizontal or vertical region for 2D plots.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_linear_region_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_linear_region.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw an LinearRegion</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates use of special Camera subclasses to implement a (flashy)  data-exploration tool.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_magnify_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_magnify.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Zoom in using MagnifyCamera</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Draw spherical Markers with Tube meshes connecting them.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_marker_spheres_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_marker_spheres.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Spheres and Sticks</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple test of nested viewboxes, demonstrating the three methods that can be used by a viewbox to provide clipping.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_nested_viewbox_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_nested_viewbox.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nested Viewboxes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates use of visual.Markers to create a point cloud with a standard turntable camera to fly around with and a centered 3D Axis.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_point_cloud_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_point_cloud.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create a Point Cloud</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of PolygonVisual, EllipseVisual, RectangleVisual and RegularPolygon">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_polygon_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_polygon.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Shape Visuals</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to create a sphere.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_save_animation_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_save_animation.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create and Save Animation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="For testing zoom sensitivity on various platforms">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_sensitivity_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_sensitivity.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Zoom Sensitivity</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple demonstration of drawing and editing shapes with the mouse This demo implements mouse picking on visuals and markers using the vispy scene and &quot;visual_at&quot; mechanism. Left mouse button on empty space creates new objects. Objects can be selected by clicking, and moved by dragging. Dragging control points changes the size of the object. Vispy takes care of coordinate transforms from screen to ViewBox - the demo works on different zoom levels. Lastly, additional objects are added to the view in a fixed position as &quot;buttons&quot; to select which type of object is being created. Selecting the arrow symbol will switch into select/pan mode where the left drag moves the workplane or moves objects/controlpoints.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_shape_draw_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_shape_draw.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw and Edit Shapes with Mouse</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to create a sphere.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_sphere_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_sphere.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw a Sphere</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate the use of text in the root scene and a viewbox. Note how the point size is independent of scaling of viewbox and canvas.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_text_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_text.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Text in a Scene and ViewBox</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simple use of SceneCanvas to display a cube with an arcball camera.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_turntable_box_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_turntable_box.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Display a Cube</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate ViewBox using various clipping methods.">

.. only:: html

  .. image:: /gallery/scene/images/thumb/sphx_glr_viewbox_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_viewbox.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ViewBox with Clipping Methods</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /gallery/scene/background_borders
   /gallery/scene/colorbar_widget
   /gallery/scene/colored_line
   /gallery/scene/console
   /gallery/scene/graph
   /gallery/scene/infinite_line
   /gallery/scene/instanced_markers
   /gallery/scene/instanced_quad_visual
   /gallery/scene/isocurve
   /gallery/scene/isocurve_for_trisurface
   /gallery/scene/isocurve_for_trisurface_qt
   /gallery/scene/isocurve_updates
   /gallery/scene/isosurface
   /gallery/scene/lasso
   /gallery/scene/line
   /gallery/scene/line_update
   /gallery/scene/linear_region
   /gallery/scene/magnify
   /gallery/scene/marker_spheres
   /gallery/scene/nested_viewbox
   /gallery/scene/point_cloud
   /gallery/scene/polygon
   /gallery/scene/save_animation
   /gallery/scene/sensitivity
   /gallery/scene/shape_draw
   /gallery/scene/sphere
   /gallery/scene/text
   /gallery/scene/turntable_box
   /gallery/scene/viewbox

Grid Layouts
============

Examples of using the GridWidget to layout elements in a SceneCanvas.



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Test automatic layout of multiple viewboxes using Grid.">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multiple ViewBoxes on a Grid</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip=" +-----+-----+ |     |     | |  1  |  2  | |     |     | +-----+-----+">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_basic_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid_basic.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Simple use of a grid layout</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="::">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_holed_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid_holed.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">More complex grid layout</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Test automatic layout of multiple viewboxes using Grid.">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_large_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid_large.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multiple Line Views on a Grid</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="+-----+-----+-----+ |  1  |  2  |  2  | +-----+-----+-----+ |  3  |  3  |  4  | +-----+-----+-----+">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_uneven_col_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid_uneven_col.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Another Grid Layout</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="+----+-------------+ |    |             | | y  |   viewbox   | |    |             | +----+-------------+ | sp |     x       | +----+-------------+">

.. only:: html

  .. image:: /gallery/scene/grid_layout/images/thumb/sphx_glr_grid_x_y_viewbox_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_grid_layout_grid_x_y_viewbox.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot-like Grid Layout</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

Realtime Data Tutorial
======================

Examples that progressively build a Qt-based visualization application
with updating data. The data in this tutorial is artificial, but is created
and used in a way resembling real world data streams. In early examples data
is created in the main GUI thread, but creation is later moved to an external
thread to promote better responsiveness from the GUI.

Each example is a self-contained working application in some sense and can be
used as a reference for the particular feature it is demonstrating. However,
each example builds on the example before it so features and
vispy application best practices are improved at the cost of more complex code.

Lastly, these examples use PySide2, but the application
structure and demonstrated concepts should apply and be transferable to other
backends (especially the Qt ones) with only a few exceptions. At the time of
writing PySide2 is the newest version of PySide available through conda-forge
conda channels. If/when PySide6 is available, pull requests to update these
examples would be welcome. ;)



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Display VisPy visualizations in a PyQt5 application.">

.. only:: html

  .. image:: /gallery/scene/realtime_data/images/thumb/sphx_glr_ex01_embedded_vispy_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_realtime_data_ex01_embedded_vispy.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Embed VisPy into Qt</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Control a VisPy visualization with Qt-based (PyQt5) UI elements.">

.. only:: html

  .. image:: /gallery/scene/realtime_data/images/thumb/sphx_glr_ex02_control_vispy_from_qt_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_scene_realtime_data_ex02_control_vispy_from_qt.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Control VisPy from Qt</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Update VisPy visualizations from a QTimer in the main GUI thread.">

.. only:: html

  .. image:: /gallery/scene/realtime_data/images/thumb/sphx_glr_ex03a_data_sources_timer_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_realtime_data_ex03a_data_sources_timer.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Update data using timer-based events</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Update VisPy visualizations from a background QThread.">

.. only:: html

  .. image:: /gallery/scene/realtime_data/images/thumb/sphx_glr_ex03b_data_sources_threaded_loop_thumb.gif
    :alt:

  :ref:`sphx_glr_gallery_scene_realtime_data_ex03b_data_sources_threaded_loop.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Update data using a loop in a background thread</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /gallery/scene/grid_layout/index.rst
   /gallery/scene/realtime_data/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: scene_python.zip </gallery/scene/scene_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: scene_jupyter.zip </gallery/scene/scene_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
