-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow passing graph level attributes to graphviz #7741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,6 +430,9 @@ | |
] | ||
|
||
|
||
GraphAttrMapping = dict[Any, Any] | ||
|
||
|
||
def make_graph( | ||
name: str, | ||
plates: list[Plate], | ||
|
@@ -439,6 +442,7 @@ | |
figsize=None, | ||
dpi=300, | ||
node_formatters: NodeTypeFormatterMapping | None = None, | ||
graph_attrs: GraphAttrMapping | None = None, | ||
|
||
create_plate_label: PlateLabelFunc = create_plate_label_with_dim_length, | ||
): | ||
"""Make graphviz Digraph of PyMC model. | ||
|
@@ -460,6 +464,9 @@ | |
node_formatters = update_node_formatters(node_formatters) | ||
|
||
graph = graphviz.Digraph(name) | ||
if graph_attrs is not None: | ||
graph.attr(**graph_attrs) | ||
|
||
zaxtax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
for plate in plates: | ||
if plate.dim_info: | ||
# must be preceded by 'cluster' to get a box around it | ||
|
@@ -676,6 +683,7 @@ | |
figsize: tuple[int, int] | None = None, | ||
dpi: int = 300, | ||
node_formatters: NodeTypeFormatterMapping | None = None, | ||
graph_attrs: GraphAttrMapping | None = None, | ||
include_dim_lengths: bool = True, | ||
): | ||
"""Produce a graphviz Digraph from a PyMC model. | ||
|
@@ -704,6 +712,10 @@ | |
the size of the saved figure. | ||
dpi : int, optional | ||
Dots per inch. It only affects the resolution of the saved figure. The default is 300. | ||
graph_attrs : dict, optional | ||
A dictionary of top-level layout attributes for graphviz | ||
Check out graphviz documentation for more information on available attributes | ||
https://graphviz.org/doc/info/attrs.html | ||
node_formatters : dict, optional | ||
A dictionary mapping node types to functions that return a dictionary of node attributes. | ||
Check out graphviz documentation for more information on available | ||
|
@@ -773,6 +785,7 @@ | |
save=save, | ||
figsize=figsize, | ||
dpi=dpi, | ||
graph_attrs=graph_attrs, | ||
node_formatters=node_formatters, | ||
create_plate_label=create_plate_label_with_dim_length | ||
if include_dim_lengths | ||
|
Uh oh!
There was an error while loading. Please reload this page.