causalnex.plots.plot_structure¶
-
causalnex.plots.
plot_structure
(sm, all_node_attributes=None, all_edge_attributes=None, node_attributes=None, edge_attributes=None, plot_options=None)[source]¶ Plot a StructureModel using pyvis.
Return a pyvis graph object - which can be visualized using the pyvis method .show(name)
Default node, edge, and graph attributes are provided to style and layout the plot. These defaults can be overridden for all nodes and edges through all_node_attributes and all_edge_attributes respectively. Graph attributes can be overridden through graph_attributes.
Styling and layout attributes can be set for individual nodes and edges through node_attributes and edge_attributes respectively.
Attributes are set in the following order, overriding any previously set attributes 1. default attributes 2. all_node_attributes and all_edge_attributes 3. node_attributes and edge_attributes
Detailed documentation on available attributes and how they behave is available at: https://visjs.github.io/vis-network/docs/network/.
Default style attributes provided in CausalNex are:
causalnex.plots.GRAPH_STYLE - defaults graph styling
causalnex.plots.NODE_STYLE.NORMAL - default node styling
causalnex.plots.NODE_STYLE.WEAK - intended for less important nodes in structure
causalnex.plots.NODE_STYLE.STRONG - intended for more important nodes in structure
causalnex.plots.EDGE_STYLE.NORMAL - default edge styling
causalnex.plots.EDGE_STYLE.WEAK - intended for less important edges in structure
causalnex.plots.EDGE_STYLE.STRONG - intended for more important edges in structure
Example:
from causalnex.plots import plot_structure plot = plot_structure(structure_model)
- Parameters
sm (
DiGraph
) – structure to plotall_node_attributes (
Optional
[Dict
[str
,str
]]) – attributes to apply to all nodesall_edge_attributes (
Optional
[Dict
[str
,str
]]) – attrinbutes to apply to all edgesnode_attributes (
Optional
[Dict
[str
,Dict
[str
,str
]]]) – attributes to apply to specific nodesedge_attributes (
Optional
[Dict
[Tuple
[str
,str
],Dict
[str
,str
]]]) – attributes to apply to specific edgesplot_options (
Optional
[Dict
[str
,str
]]) – attributes to apply to pyvis plotting function
- Return type
Network
- Returns
a styled pyvis graph that can be rendered externally as an HTML object