Skip to content

Instantly share code, notes, and snippets.

/pydot_bug.py Secret

Created March 8, 2015 15:39
Show Gist options
  • Save anonymous/c0d25fa7fad6ac7a1be6 to your computer and use it in GitHub Desktop.
Save anonymous/c0d25fa7fad6ac7a1be6 to your computer and use it in GitHub Desktop.
Issue attachments for pydot/pydot-ng#80: https://github.com/pydot/pydot-ng/issues/80
import pydot
g = pydot.graph_from_dot_data("digraph G {1 -> 2;}")
print("Simple DOT:\n{0}".format(g.to_string()))
print("Nodes: {0}, edges: {1}".format(len(g.get_nodes()), len(g.get_edges())))
g.write_png("simple.png")
g.set_node_defaults(style="filled", fillcolor="yellow")
print("DOT with yellow fill (wrong):\n{0}".format(g.to_string()))
g.write_png("simple.yellow.png")
g = pydot.graph_from_dot_data("""
digraph G {
node [style=filled, fillcolor=yellow];
1 -> 2;
}
""")
print("DOT with yellow fill (good):\n{0}".format(g.to_string()))
g.write_png("simple.good.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment