pyvista-support icon indicating copy to clipboard operation
pyvista-support copied to clipboard

Plotting without Graphical Back-End

Open MarkusZimmerDLR opened this issue 3 years ago • 3 comments

Dear pyvista-folks,

I am thinking about adding a postprocessing step to my calculations on an HPC-cluster, using pyvista.

Is it somehow possible to save plots (png/svg) without a graphical back-end? For example on matplotlib I use the AGG back-end.

The following code still opens a window for rendering and I need a way to circumvent this.

import pyvista as pv
mesh = pv.Sphere()
mesh.plot(screenshot='test.png', offscreen=True)
pyvista: 0.28.1
vtk: 8.1.2

Cheers, Markus

MarkusZimmerDLR avatar Mar 15 '21 11:03 MarkusZimmerDLR

Just ran into this issue a moment ago. The issue is that VTK needs to start some sort of render window with the vanilla VTK wheel or conda package. If you want to, you can always use the EGL wheels at Release 0.27, but more often than not, just starting a xvfb virtual buffer works. Use:

import pyvista as pv
pv.start_xvfb()

You may have to install some additional packages, but it's the easiest way of setting up a virtual framebuffer.

akaszynski avatar Mar 15 '21 20:03 akaszynski

I may be mistaken, but in pyvista 0.28.1 I do not see a pv.start_xvfb() function. Is this specific to 0.27 ?

MarkusZimmerDLR avatar Mar 17 '21 10:03 MarkusZimmerDLR

Sorry, should have looked at your version. We just added that in pyvista==0.29.0.

akaszynski avatar Mar 17 '21 11:03 akaszynski