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.

G. Anderson
  • 5,815
  • 2
  • 14
  • 21
  • _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. – AMC Jan 07 '20 at 21:44
  • The code you have so far looks fine, is it not working? Have you seen [this other relevant question](https://stackoverflow.com/q/25698448/11301900)? – AMC Jan 09 '20 at 17:45

2 Answers2

0

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)
Luca R
  • 197
  • 2
  • 14
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)

Adé
  • 1