October 21, 2024
Chicago 12, Melborne City, USA
HTML

Is it possible to have Plotly HTML charts appear within Colab without running the code beforehand?


I recently created a Python script that retrieves recent weather reports from the National Weather Service, then creates some simple Plotly visualizations of temperature and precipitation data. I configured a spare laptop to run this script on an hourly basis and then export the output to Google Drive, thus allowing relatively recent data to appear within this Colab notebook.

If I run and save this notebook on my local computer, then close and reopen it within JupyterLab Desktop or VS Code, the Plotly HTML-based charts will still appear (as long as Plotly is present within the active environment). In addition, if I run the notebook within Colab, the HTML charts will get produced there also.

However, I’m wondering whether it’s possible for the interactive Plotly charts to appear within Colab without running the Colab notebook beforehand. This notebook does display static PNG copies of each chart by default, but until I actually run the notebook online, I only see blank spaces where the HTML charts should be:

missing_chart

(This screenshot from JupyterLab Desktop shows what I’d expect to see instead. Note that this HTML chart appeared by default when I opened the notebook; there was no need to run the script after opening JupyterLab in order to view this chart.)

present_chart

In this case, it’s not much trouble to just go ahead and run the notebook; however, other notebooks may make use of local files and folders and thus couldn’t easily be run by others within Colab. Therefore, I’d love to find a method for showing interactive charts within Colab that doesn’t require actually running the notebook.

Thank you in advance for your help!

PS: I know that an alternative setup would be to just display these interactive charts within a Dash app, but I may sometimes prefer to use a Jupyter Notebook as my medium in order to more easily display both my code and its output.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video