def fig_to_vega(fig, notebook=False):
 renderer = VegaRenderer()
 Exporter(renderer).run(fig)
 vega_html = VegaHTML(renderer)
 if notebook:
  return vega_html
 else:
  return vega_html.html()

def fig_to_vega ( fig , notebook = False ) : renderer = VegaRenderer ( ) Exporter ( renderer ) . run ( fig ) vega_html = VegaHTML ( renderer ) if notebook : return vega_html else : return vega_html . html ( )
convert a matplotlib figure to vega dictionary if notebook=true .