Skip to content

Alwinator/graphviz-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0ad065c · Jan 23, 2024

History

49 Commits
Sep 25, 2022
Feb 16, 2022
Feb 15, 2022
Feb 16, 2022
Mar 9, 2022
Feb 15, 2022
Feb 15, 2022
Jan 17, 2024
Mar 9, 2022

Repository files navigation

graphviz-py

package version py versions pypi license

Allows Python code execution inside of graphviz diagrams

Example

graph python_graph {
{{
import math

value = 0.5
sin = math.sin(value)
cos = math.cos(value)
}}

A [label="{{= value }}"];
B [label="{{= sin }}"];
C [label="{{= cos }}"];

A -- B [headlabel="sin"];
A -- C [headlabel="cos"];

}

Output

output

Installation

pip install graphviz-py

Important: Make sure graphviz is installed! See graphviz installation instructions.

Usage

Using files

graphviz-py -Tsvg example/example.py.dot -o output.svg
graphviz-py -Tpng example/example.py.dot -o output.png

Using stdin / pipes

echo 'digraph { A -> B [label="{{= 38 * 73 }}"] }' | graphviz-py -Tsvg > output.svg

graphviz-py passes all unknown arguments to graphviz. So you can use all graphviz arguments.

Output

output

Variables

graphviz-py -Tsvg -a myvalue=5 example/variable_example.py.dot -o output.svg

Here we pass a variable called "myvalue" with the value 5

Output

output

Security

Please keep in mind that graphviz-py executes all Python code in the diagram. So make sure that your diagrams do not include harmful code.

Coming soon

Arguments

# graphviz-py --help
usage: graphviz-py [-h] [-v] [-d] [-a ARGUMENT] [files [files ...]]

graphviz-py diagram builder

positional arguments:
  files                 the paths to the graphviz-py files

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -d, --debug           show debug information
  -a ARGUMENT, --argument ARGUMENT