make html
in the doc
directory. Note however that by default it will run all of the gallery examples which can take a long time. There is a way to make it not do that but I don't remember off the top of my head
# -*- coding: utf-8 -*-
# vispy: gallery 30
# -----------------------------------------------------------------------------
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
"""
Draw a SurfacePlot
==================
This example demonstrates the use of the SurfacePlot visual.
"""
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), shading='smooth')
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)
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()
@brisvag The above is a sample code from vispy github and these are the results with old and new versions of the library.
@sreenath1994s it seems that the crux of the issue is that the default light direction changed. Not sure why or when; you problem can be easily fixed by changing the light direction to something better. In the example above:
p1.shading_filter.light_dir = 1, 1, 1
this should be close enought to what you had before. If not, play around with the number until you're happy :)
p1.shading_filter?
and it will give you the documentation for it
Z[index:index+chunk_size] = chunk, index += chunk_size
But you have to take care of the case where index is close to the end of Z. in such case, you need to split your data in two parts and make 2 uploads.
np.roll
. You could also do this kind of thing on a numpy array that's 2 times the size of the buffer you need and treat it like a circular buffer. You update the array in two places with your new chunk, but the data you upload to matplotlib/vispy is the slice of the large array that represents the current N data points.