Exporting plots from Slicer

Beyond screen capture, what is the option to export a plot from Slicer. If possible in SVG format or at least some bitmap?

VTK should be able to export plots as postscript file (see https://vtk.org/doc/nightly/html/classvtkGL2PSExporter.html). You may also experiment with anti-aliasing options and view size to get high-quality output suitable for printing.

Thanks @lassoan. Will take a careful look. Cursory examination suggests it is dependent on a library called gl2ps (http://www.geuz.org/gl2ps/), is this available with the VTK distributed with Slicer, or would it require custom build?

I didn’t try with a plot, but the class does work in Slicer as shown below. Looks like we just need to add an accessor to get the renderWindow from a chart view.

>>> e = vtk.vtkGL2PSExporter()
>>> e.SetFileFormatToSVG()
>>> lm = slicer.app.layoutManager()
>>> e.SetRenderWindow(lm.sliceWidget('Red').sliceView().renderWindow())
>>> e.SetFilePrefix('/tmp/red')
>>> e.Update()

image

@pieper my specific concerns is the Plots. Slice view is straightforward with available Snapshot tool.
SVG is more relevant for plots, as the user can modify the colors/symbols etc…

Of course I know that!

This was just a demo to show you that the gl2ps code is bundled with Slicer. The plots should work the same if one used their render window instead of the slice view render window.

I added a hook to export plots svg, which is available via python for now. I’m thinking it would make sense to add a Save As button to the qMRMLPlotViewControllerWidget for this.

image

I went ahead and added a Save button to the plot controller popup. I also confirmed the SVG output is in vector form, not raster, so it should look good in print or at least it won’t have rasterization effects).