1

I am new to programming, so forgive the question if it seems simple.

I have been using Python and its libraries to make plots. I am attempting to import an interactive graph I plotted using the plotly graphing library and display it in the Jupyter notebook.

The graph is saved as an html file. I need the graph to remain as an html file to retain the graph's features and interactivity (zooming in/out, changing the scales, hiding certain data, etc).

So far, I have written out this bit of code:

import plotly
import os

os.chdir(r'C:\Users\alsha\Documents\CE-CERT - SIGI\CMC Data')

from IPython.display import HTML
HTML(filename="./CopperMountainCollegeEntireInterval.html")

I do not know what code to write to display the actual graph, I would appreciate any help I receive.

2
  • I do not know what code to write to display the actual graph Stack Overflow is meant for specific technically issues, so this is unfortunately off topic as it is far too broad. Commented Jan 7, 2020 at 21:44
  • The code you have so far looks fine, is it not working? Have you seen this other relevant question? Commented Jan 9, 2020 at 17:45

2 Answers 2

1

I am probably a year to late, but the easiest way would be to import IFrame from IPython.display and use it like

from IPython.display import IFrame
IFrame(src='path_to_html', width=500, height=500)
Sign up to request clarification or add additional context in comments.

Comments

0

To complete Luca R answer (his solution works fine): In my case though, I noticed that to use IFrame, I needed to place the html file in the same directory as my notebook (or in a subdirectory under the notebook) and then use a relative path. It is probably due to common browser security settings (see more from https://community.plotly.com/t/displaying-html-file-generated-by-plotly-offline-in-a-jupyter-notebook/19586)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.