Skip to content

Instantly share code, notes, and snippets.

@marcocamma
Last active March 14, 2023 21:29
Show Gist options
  • Save marcocamma/d84d283522d3a42cd3f6eef4c6643c81 to your computer and use it in GitHub Desktop.
Save marcocamma/d84d283522d3a42cd3f6eef4c6643c81 to your computer and use it in GitHub Desktop.
Exporting matplotlib figure as interactive plotly figure
# tested with plotly 5.13.1, matplotlib 3.5.3
from matplotlib import pyplot as plt
import plotly.tools as tls
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
plt.plot([1,2,3])
fig=plt.gcf()
fig_plotly=tls.mpl_to_plotly(fig)
fig_plotly.write_html("my_image.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment