Skip to content

plot_identification

Signature/Parameters

def plot_identification(self, content = 'default', effect = 'total', show_np = True, show_linear = True, show_do = True, kws_graph = {}, kws_identification = {}, kws_detailed = None, figsize = None, ratio = None, ncols = None, nrows = None, title_dag = None, title_info = None, txt_line_height = 0.55, *args, **kws)

Plot identification information alongside the DAG.

Parameters:

Name Type Description Default
content (default, detailed)

Level of detail displayed in the identification summary. Defaults to 'default'.

'default'
effect (total, direct, do)

Effect type to highlight when content requires it. Defaults to 'total'.

'total'
show_np bool

Toggle inclusion of non-parametric, linear, and do-calculus strategies in the summary. All default to True.

True
show_linear bool

Toggle inclusion of non-parametric, linear, and do-calculus strategies in the summary. All default to True.

True
show_do bool

Toggle inclusion of non-parametric, linear, and do-calculus strategies in the summary. All default to True.

True
kws_graph dict

Keyword arguments forwarded to DAG.plot for the DAG panel.

{}
kws_identification dict

Arguments passed to identification_analysis before plotting.

{}
kws_detailed dict or None

Overrides for detailed identification output (e.g., {'strategy': 'SoO', 'parameter': 'ACE'}). Defaults to selecting the first available parameter.

None
figsize tuple[float, float] or None

Figure size in inches. When None, the identification plotting routine chooses a default.

None
ratio float or None

Aspect ratio override for the combined plot.

None
ncols int or None

Layout configuration for identification panels.

None
nrows int or None

Layout configuration for identification panels.

None
title_dag str or None

Title displayed above the DAG subplot.

None
title_info str or None

Title for the identification summary panel.

None
txt_line_height float

Text line height used when figsize is not provided. Defaults to 0.55.

0.55
*args

Additional positional arguments forwarded to the underlying plotting routine.

()
**kws

Extra keyword arguments forwarded to the underlying plotting routine.

{}

Returns:

Type Description
tuple

Result of self.__identification__.plot which includes figure and axes handles.

Examples:

>>> G = DAG(graph="X -> Y")
>>> G.identification_analysis(exposure="X", outcome="Y", verbose=False)
>>> result = G.plot_identification(show_plot=False)
Source code in causalinf/gcm.py
def plot_identification(self,
                        content='default', # detailed, default
                        effect='total', #total, direct, or do, only if if_info=full
                        show_np = True,
                        show_linear = True,
                        show_do = True,
                        kws_graph={},
                        kws_identification={},
                        kws_detailed = None,
                        figsize = None,
                        ratio   = None,
                        ncols   = None,
                        nrows   = None,
                        title_dag = None,
                        title_info = None,
                        txt_line_height=.55,
                        *args,
                        **kws
                        ):
    """
    Plot identification information alongside the DAG.

    Parameters
    ----------
    content : {'default', 'detailed'}, optional
        Level of detail displayed in the identification summary. Defaults to
        ``'default'``.
    effect : {'total', 'direct', 'do'}, optional
        Effect type to highlight when ``content`` requires it. Defaults to
        ``'total'``.
    show_np, show_linear, show_do : bool, optional
        Toggle inclusion of non-parametric, linear, and do-calculus
        strategies in the summary. All default to ``True``.
    kws_graph : dict, optional
        Keyword arguments forwarded to ``DAG.plot`` for the DAG panel.
    kws_identification : dict, optional
        Arguments passed to ``identification_analysis`` before plotting.
    kws_detailed : dict or None, optional
        Overrides for detailed identification output (e.g.,
        ``{'strategy': 'SoO', 'parameter': 'ACE'}``). Defaults to selecting
        the first available parameter.
    figsize : tuple[float, float] or None, optional
        Figure size in inches. When ``None``, the identification plotting
        routine chooses a default.
    ratio : float or None, optional
        Aspect ratio override for the combined plot.
    ncols, nrows : int or None, optional
        Layout configuration for identification panels.
    title_dag : str or None, optional
        Title displayed above the DAG subplot.
    title_info : str or None, optional
        Title for the identification summary panel.
    txt_line_height : float, optional
        Text line height used when ``figsize`` is not provided. Defaults to
        ``0.55``.
    *args :
        Additional positional arguments forwarded to the underlying plotting
        routine.
    **kws :
        Extra keyword arguments forwarded to the underlying plotting routine.

    Returns
    -------
    tuple
        Result of ``self.__identification__.plot`` which includes figure and
        axes handles.

    Examples
    --------
    >>> G = DAG(graph="X -> Y")
    >>> G.identification_analysis(exposure="X", outcome="Y", verbose=False)
    >>> result = G.plot_identification(show_plot=False)
    """
    roles = ['Exposure', 'Outcome', 'Latent', 'Observed',
             'exposure', 'outcome', 'latent', 'observed']
    for role in roles:
        assert not kws_graph.get(role, None) and not kws_identification.get(role, None), (
            f"Setting node role ({role}) not allowed in the plot kws. "+
            f"To set the node role, create a new DAG or use set_node_role before plotting.")

    if not self.__identification__ or kws_identification:
        self.identification_analysis(**kws_identification, verbose=False)

    # defaults for kws_detailed
    kws_detailed = kws_detailed or {}
    strategy = kws_detailed.get('strategy', 'SoO')
    parameter = kws_detailed.get('parameter', None)
    if not parameter:
        parameter = next(iter(self.__identification__.identification[strategy]))
    kws_detailed['strategy'] = strategy
    kws_detailed['parameter'] = parameter

    return self.__identification__.plot(G=self,
                                        info=content,
                                        effect=effect,
                                        show_np = show_np,
                                        show_linear = show_linear,
                                        show_do = show_do,
                                        figsize=figsize,
                                        ratio=ratio,
                                        ncols=ncols,
                                        nrows=nrows,
                                        kws_graph=kws_graph,
                                        kws_detailed = kws_detailed,
                                        txt_line_height=txt_line_height,
                                        title_dag = title_dag,
                                        title_info = title_info,
                                        *args,
                                        **kws
                                        )