0

作为标题,仅打印白色图像。

下面是我的代码

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)

我得到 vispytest.png在此处输入图像描述

我在 Linux 上使用 Xvfb。

Xvfb :1 -screen 0 2500x1500x24 -auth localhost

谢谢你。

4

1 回答 1

0

问题是相机的焦点,必须修改,类似于以下内容:

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

完整代码:

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

在此处输入图像描述

于 2017-06-22T03:17:45.990 回答