Reputation: 1345
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.
Upvotes: 4
Views: 3263
Reputation: 1642
Here is an updated version jvtrudel's of answer (working with vispy 0.5.0-dev):
The official demo https://github.com/vispy/vispy/blob/master/examples/basics/plotting/export.py does something very similar, and a stripped down version adjusted to export a png could look like this:
import vispy.plot as vp
import vispy.io as io
fig = vp.Fig(show=False)
fig[0, 0].plot([1, 6, 2, 4, 3, 8, 5, 7, 6, 3])
image = fig.render()
io.write_png("wonderful.png",image)
Upvotes: 1
Reputation: 1345
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)
Upvotes: 8