Skip to content

Commit

Permalink
feat: allow size control of PAG render
Browse files Browse the repository at this point in the history
  • Loading branch information
guyazran committed Dec 18, 2022
1 parent a5fe9bf commit 324df2e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plot_utils/draw_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def draw_node(axes, pos, node_radius,


def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white', fgcolor='black', line_color='auto',
layout_type=None):
layout_type=None, node_labels=None, top=1, right=1):
"""
Draw a graph. Currently supported graph types are DAG and PAG. Matplotlib is used as a backend.
:param graph: the graph to be plotted
Expand All @@ -168,6 +168,7 @@ def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white',
:param fgcolor: foreground color of the node
:param line_color: color of the node contour and text
:param layout_type: type of node position layout: 'circular' or 'force' (default; force-directed algorithm)
:param node_labels: a mapping from node ID's to desired labels in the rendered graph.
:return:
"""
assert isinstance(graph, (DAG, PAG))
Expand All @@ -177,9 +178,9 @@ def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white',
latent_nodes = set()

bottom = 0
top = 1
# top = 1
left = 0
right = 1
# right = 1
node_radius = 0.04
width = right - left
height = top - bottom
Expand Down Expand Up @@ -221,7 +222,7 @@ def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white',
contour = 'circle'
fg = fgcolor
bk = bkcolor
draw_node(ax, nodes_pos[node], node_radius=node_radius, node_name=str(node), contour=contour,
draw_node(ax, nodes_pos[node], node_radius=node_radius, node_name=node_labels[node], contour=contour,
line_color=fgcolor, fill_color=bk, text_color=fg)

if isinstance(graph, PAG):
Expand Down

0 comments on commit 324df2e

Please sign in to comment.