code: def fig_to_vega(fig, notebook=False):
      """Convert a matplotlib figure to vega dictionary
  
      if notebook=True, then return an object which will display in a notebook
      otherwise, return an HTML string.
      """
      renderer = VegaRenderer()
      Exporter(renderer).run(fig)
      vega_html = VegaHTML(renderer)
      if notebook:
          return vega_html
      else:
          return vega_html.html()
  
file_path: catboost/contrib/python/plotly/py3/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py
imports: import warnings
  import json
  import random
  from .base import Renderer
  from ..exporter import Exporter
label_desc: Use image node_id 1 for calling a global function with example usage: fig_to_vega(fig, notebook) and returns: vega_html, vega_html