Black Lives Matter. Please consider donating to Black Girls Code today.

Embedding Graphs in HTML in Python

How to embed plotly graphs with an iframe in HTML.


New to Plotly?

Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

Plotly graphs can be embedded in any HTML page. This includes IPython notebooks, Wordpress sites, dashboards, blogs, and more.

For more on embedding Plotly graphs in HTML documents, see our tutorial.

From Python, you can generate the HTML code to embed Plotly graphs with the plotly.tools.get_embed function.

In [1]:
import chart_studio.tools as tls

tls.get_embed('https://plotly.com/~chris/1638')
Out[1]:
'<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="https://plotly.com/~chris/1638.embed" height="525" width="100%"></iframe>'