Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export VisPy result as png image

Is it possible to save images made with VisPy? Maybe using vispy.io.imsave or vispy.write_png?

Also, it is possible to plot matplotlib figures in vispy using vispy.mpl_plot but is it possible to use a vispy image in matplotlib?

In any case, I would need to generate an image object with VisPy but I did not find any example of that.

like image 435
jvtrudel Avatar asked Feb 10 '23 20:02

jvtrudel


1 Answers

Here is a minimal example. Use canvas.render to create an image, then export it with io.write_png:

import vispy.plot as vp 
import vispy.io as io

# Create a canvas showing plot data 
canvas = vp.plot([1, 6, 2, 4, 3, 8, 5, 7, 6, 3])

# Use render to generate an image object
img=canvas.render()

# Use write_png to export your wonderful plot as png ! 
io.write_png("wonderful.png",img)
like image 179
jvtrudel Avatar answered Feb 13 '23 10:02

jvtrudel