MCPcopy Create free account
hub / github.com/plotly/plotly.py / fig_to_vega

Function fig_to_vega

plotly/matplotlylib/mplexporter/renderers/vega_renderer.py:127–139  ·  view source on GitHub ↗

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.

(fig, notebook=False)

Source from the content-addressed store, hash-verified

125
126
127def fig_to_vega(fig, notebook=False):
128 """Convert a matplotlib figure to vega dictionary
129
130 if notebook=True, then return an object which will display in a notebook
131 otherwise, return an HTML string.
132 """
133 renderer = VegaRenderer()
134 Exporter(renderer).run(fig)
135 vega_html = VegaHTML(renderer)
136 if notebook:
137 return vega_html
138 else:
139 return vega_html.html()
140
141
142VEGA_TEMPLATE = """

Callers

nothing calls this directly

Calls 5

htmlMethod · 0.95
VegaRendererClass · 0.85
ExporterClass · 0.85
VegaHTMLClass · 0.85
runMethod · 0.45

Tested by

no test coverage detected