Saving a graph as an image
by: Kevin Broløs
(Feyn version 1.4 or newer)
Our graphs are rendered in SVG, but in some cases, you might want to export them for other uses.
As of now, the way to do that is to get the SVG string from our renderer using the function _repr_svg_
, and save it to a file.
Here's an example:
from feyn import QLattice
qlattice = QLattice()
qgraph = qlattice.get_classifier(['Hello'], 'World')
g = qgraph[0]
with open(f'./graph0.svg', 'w') as fd:
fd.write(g._repr_svg_())