用Vispy绘制后,只得到白色图像

2024-04-26 02:50:01 发布

您现在位置:Python中文网/ 问答频道 /正文

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

下面是我的代码

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.pngenter image description here

我在Linux上使用Xvfb。在

^{pr2}$

谢谢。在


Tags: ioimportviewadd标题imgpngnp