code: def plot(
      causal_graph: nx.Graph,
      layout_prog: Optional[str] = None,
      causal_strengths: Optional[Dict[Tuple[Any, Any], float]] = None,
      colors: Optional[Dict[Union[Any, Tuple[Any, Any]], str]] = None,
      filename: Optional[str] = None,
      display_plot: bool = True,
      figure_size: Optional[Tuple[int, int]] = None,
      **kwargs,
  ) -> None:
      """Convenience function to plot causal graphs. This function uses different backends based on what's
      available on the system. The best result is achieved when using Graphviz as the backend. This requires both
      the shared system library (e.g. ``brew install graphviz`` or ``apt-get install graphviz``) and the Python pygraphviz
      package (``pip install pygraphviz``). When graphviz is not available, it will fall back to the networkx backend.
  
      :param causal_graph: The graph to be plotted
      :param layout_prog: Defines the layout type. If None is given, the 'dot' layout is used for graphviz plots and a
                          customized layout for networkx plots.
      :param causal_strengths: An optional dictionary with Edge -> float entries.
      :param colors: An optional dictionary with color specifications for edges or nodes.
      :param filename: An optional filename if the output should be plotted into a file.
      :param display_plot: Optionally specify if the plot should be displayed or not (default to True).
      :param figure_size: A tuple to define the width and height (as a tuple) of the pyplot. This is used to parameter to
                          modify pyplot's 'figure.figsize' parameter. If None is given, the current/default value is used.
      :param kwargs: Remaining parameters will be passed through to the backend verbatim.
  
      **Example usage**::
  
      >>> plot(nx.DiGraph([('X', 'Y')])) # plots X -> Y
      >>> plot(nx.DiGraph([('X', 'Y')]), causal_strengths={('X', 'Y'): 0.43}) # annotates arrow with 0.43
      >>> plot(nx.DiGraph([('X', 'Y')]), colors={('X', 'Y'): 'red', 'X': 'green'}) # colors X -> Y red and X green
      """
      try:
          from dowhy.utils.graphviz_plotting import (
              plot_causal_graph_graphviz,
          )
  
          try:
              plot_causal_graph_graphviz(
                  causal_graph,
                  layout_prog=layout_prog,
                  causal_strengths=causal_strengths,
                  colors=colors,
                  filename=filename,
                  display_plot=display_plot,
                  figure_size=figure_size,
                  **kwargs,
              )
          except Exception as error:
              from dowhy.utils.networkx_plotting import (
                  plot_causal_graph_networkx,
              )
  
              _logger.info(
                  "There was an error when trying to plot the graph via graphviz, falling back to networkx "
                  "plotting. If graphviz is not installed, consider installing it for better looking plots. The"
                  " error is:" + str(error)
              )
  
              plot_causal_graph_networkx(
                  causal_graph,
                  layout_prog=layout_prog,
                  causal_strengths=causal_strengths,
                  colors=colors,
                  filename=filename,
                  display_plot=display_plot,
                  figure_size=figure_size,
                  **kwargs,
              )
  
      except (ImportError, ModuleNotFoundError):
          from dowhy.utils.networkx_plotting import (
              plot_causal_graph_networkx,
          )
  
          _logger.info(
              "Pygraphviz installation not found, falling back to networkx plotting. "
              "For better looking plots, consider installing pygraphviz. Note This requires both the Python "
              "pygraphviz package (``pip install pygraphviz``) and the shared system library (e.g. "
              "``brew install graphviz`` or ``apt-get install graphviz``)"
          )
  
          plot_causal_graph_networkx(
              causal_graph,
              layout_prog=layout_prog,
              causal_strengths=causal_strengths,
              colors=colors,
              filename=filename,
              display_plot=display_plot,
              figure_size=figure_size,
              **kwargs,
          )
  
file_path: dowhy/dowhy/utils/plotting.py
imports: import logging
  import os
  import tempfile
  from typing import Any, Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import networkx
  import numpy
  import pandas
  from matplotlib import image
label_desc: Use image node_id 1 for calling a global function with example usage: plot(causal_graph, layout_prog, causal_strengths, colors, filename, display_plot, figure_size) without return types