Created
August 18, 2020 17:57
-
-
Save sllynn/298d6714450823a223ebab89649b3dae to your computer and use it in GitHub Desktop.
Display a graphviz Graph or Digraph in a notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_graphviz(graph): | |
from tempfile import NamedTemporaryFile | |
from base64 import b64encode | |
with NamedTemporaryFile(suffix=".png") as fh: | |
graph.plot(to_file=fh.name) | |
img = b64encode(fh.read()).decode("UTF-8") | |
displayHTML(f"<img src='data:image/png;base64,{img}'>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment