Display/hide/update plotly offline plots in Notebook cells

I have Notebook with dahsboard add-on which has interactive menus that generate plots in different cells. I cant manage to generate the plotly plots in one cell and display them in another through menu input by the user. The various approaches for solving this have only confused me more.

Apart from a working approach I am also hoping to learn what is the proper way of doing this as I am lost in all of the possibilities.

  • I have presented the problem asking for one possible way of solving - setting destination cell for each output: here.

  • Another possible solution is to first plot empty plot in a separate cell and then update on-event from the menu. Similar questions have been asked here and here

  • Lastly, I thought about plotting in an object without displaying and then displaying in the cell that I want. However, py.offline.iplot() generates and plots at the same time. Is there a way to generate the full plot in an object and then display() in the cell that I want similarly to a widget?

Hi @KonstantinV,

I’ve not worked with the Jupyter notebook dashboard extension before. But the recommended way to update plotly figures in the Jupyter Notebook is to use the FigureWidget approach. https://plot.ly/python/figurewidget-app/. FigureWidget is itself an ipywidget so you can place it inside HBox/VBox containers to display alongside other ipywidgets. So hopefully that approach is compatible with the dashboarding approach you’re using.


I tried but
widgets.HBox([FigureWidget_plot]) or display(widgets.HBox([FigureWidget_plot]))

doesn’t actually plot the widget. For this I need:

which creates a plot that is not automatically updated when the data is changed. In the second link that I posted above, it is argued that offline plots do not have update functionality but I am not sure if this is true.

Hi @KonstantinV,

In order to get the live updating behavior we’ll need to get the native widget display approach working for you. If a FigureWidget is displayed using iplot, it’s basically converted to a standard Figure internally. Are you using the classic notebook or JupyterLab?

If you haven’t already, double check your installed versions of everything with the installation instructions at https://github.com/plotly/plotly.py#installation. If you’re using the classic notebook, check the result of $ jupyter nbextension list, if you’re using JupyterLab, check the result of $ jupyter labextension list.

Another thing to do is to check your browser JavaScript console when attempting to display the FigureWidget and see if there are any JavaScript errors being raised.


Thank you for the reply. I thought that the problem could be from the versions but I was hoping this was not the case.

I already had such problem with the latest Notebook versions which do not work well with the Dashboards extension. This forced me to downgrade the Notebook. Now if I have to align versions to get one functionality there is the risk of losing another.