Skip to content

Commit

Permalink
Update viz.py (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobrachem authored Sep 25, 2024
1 parent c117a4e commit 9235188
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions liesel/model/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
Model visualization.
"""

import logging

import matplotlib.pyplot as plt
import networkx as nx
from matplotlib.lines import Line2D

logger = logging.getLogger(__name__)


def plot_nodes(model, show=True, save_path=None, width=14, height=10, prog="dot"):
"""
Expand Down Expand Up @@ -86,6 +90,11 @@ def _prepare_figure(graph, width, height, prog):
if _is_pygraphviz_installed():
pos = nx.drawing.nx_agraph.graphviz_layout(graph, prog=prog)
else:
logger.warning(
"PyGraphviz was not found in the current environment. "
"Using fallback graph layout. Consider installing PyGraphviz: "
"https://pygraphviz.github.io/documentation/stable/install.html"
)
pos = nx.fruchterman_reingold_layout(graph)

return fig, axis, pos
Expand Down

0 comments on commit 9235188

Please sign in to comment.