.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scene/surface_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_gallery_scene_surface_plot.py: Draw a SurfacePlot ================== This example demonstrates the use of the SurfacePlot visual. .. GENERATED FROM PYTHON SOURCE LINES 13-59 .. image-sg:: /gallery/scene/images/sphx_glr_surface_plot_001.png :alt: surface plot :srcset: /gallery/scene/images/sphx_glr_surface_plot_001.png :class: sphx-glr-single-img .. code-block:: Python import sys import numpy as np from vispy import app, scene from vispy.util.filter import gaussian_filter canvas = scene.SceneCanvas(keys='interactive', bgcolor='w') view = canvas.central_widget.add_view() view.camera = scene.TurntableCamera(up='z', fov=60) # Simple surface plot example # x, y values are not specified, so assumed to be 0:50 z = np.random.normal(size=(250, 250), scale=200) z[100, 100] += 50000 z = gaussian_filter(z, (10, 10)) p1 = scene.visuals.SurfacePlot(z=z, color=(0.3, 0.3, 1, 1)) p1.transform = scene.transforms.MatrixTransform() p1.transform.scale([1/249., 1/249., 1/249.]) p1.transform.translate([-0.5, -0.5, 0]) view.add(p1) # p1._update_data() # cheating. # cf = scene.filters.ZColormapFilter('fire', zrange=(z.max(), z.min())) # p1.attach(cf) xax = scene.Axis(pos=[[-0.5, -0.5], [0.5, -0.5]], tick_direction=(0, -1), font_size=16, axis_color='k', tick_color='k', text_color='k', parent=view.scene) xax.transform = scene.STTransform(translate=(0, 0, -0.2)) yax = scene.Axis(pos=[[-0.5, -0.5], [-0.5, 0.5]], tick_direction=(-1, 0), font_size=16, axis_color='k', tick_color='k', text_color='k', parent=view.scene) yax.transform = scene.STTransform(translate=(0, 0, -0.2)) # Add a 3D axis to keep us oriented axis = scene.visuals.XYZAxis(parent=view.scene) if __name__ == '__main__': canvas.show() if sys.flags.interactive == 0: app.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.247 seconds) .. _sphx_glr_download_gallery_scene_surface_plot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: surface_plot.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: surface_plot.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_