Search code examples
jupyter-notebookplotlypython-sphinxplotly-python

Displaying Plotly figures in full screen in Jupyter notebooks


I have large Plotly figures and tables in my Jupyter Notebook and Sphinx-based documentation. Because the documentation page is already crowded, I would like to give the user an option to

  • Display these figures in a full-screen pop-up

or

  • Make tables scrollable instead of compressed columns, as the table layout with many columns do not work when embedded on a page

An example of a broken layout:

enter image description here

Does Plotly.py offer ways to achieve this easily? If it doesn't, can I somehow include external JavaScript on the generated Sphinx documentation page for the same effect?


Solution

  • I would suggest two solutions and I wish one of these solution at least works for you:

    • Horizontal Scrollbar: deactivate the autosizing option and choose a larger value for the width:

      fig.update_layout(autosize=False, width=2000)
      
    • Full-screen mode: activate the autosizing along with pop the plot up in a browser mode:

       fig.update_layout(autosize=True) # remove height=800
       fig.show(renderer="browser")  # remove display(fig)