0

As the title, only white image is printed.

below is my codes

import numpy as np
from vispy import io, scene

c = scene.SceneCanvas(keys='interactive', bgcolor='w', dpi=96)

view = c.central_widget.add_view()

xx, yy = np.arange(-1,1,.02),np.arange(-1,1,.02)
X,Y = np.meshgrid(xx,yy)
R = np.sqrt(X**2+Y**2)
Z = lambda t : 0.1*np.sin(10*R-2*np.pi*t)

surf = scene.visuals.SurfacePlot(xx, yy, Z(0), color=[0.5, 0.5, 0.5], shading='smooth')

view.add(surf)

img = c.render()
io.write_png("vispytest.png", img)

And I get vispytest.pngenter image description here

I'm using Xvfb on Linux.

Xvfb :1 -screen 0 2500x1500x24 -auth localhost

Thank you.

Hong
  • 15
  • 5

1 Answers1

0

The problem is the focus of the camera, must modify, something similar to the following:

view.camera = scene.TurntableCamera(up='z', fov=60)

Complete code:

import numpy as np
from vispy import io, scene

c = scene.SceneCanvas(keys='interactive', bgcolor='w', dpi=96)

view = c.central_widget.add_view()
view.camera = scene.TurntableCamera(up='z', fov=60)

xx, yy = np.arange(-1,1,.02),np.arange(-1,1,.02)
X,Y = np.meshgrid(xx,yy)
R = np.sqrt(X**2+Y**2)
Z = lambda t : 0.1*np.sin(10*R-2*np.pi*t)

surf = scene.visuals.SurfacePlot(xx, yy, Z(0), color=[0.5, 0.5, 0.5], shading='smooth')

view.add(surf)

img = c.render()
io.write_png("vispytest.png", img)

vispytest.png

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241