Skip to content

Commit

Permalink
FIX: abort update_plotly() if running through Sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Sep 27, 2023
1 parent d9240f1 commit 40a1d4c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/report/006.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@
"Making 3D Plotly plots interactive with {mod}`ipywidgets` is quite similar to the previous examples with {mod}`matplotlib`. Two recommendations are:\n",
"\n",
"1. Set `continuous_update=False`, because {mod}`plotly` is slower than {mod}`matplotlib` in updating the figure.\n",
"2. Save the camera orientation and update it after calling `Figure.show()`."
"2. Save the camera orientation and update it after calling `Figure.show()`.\n",
"3. When embedding the notebook a static webpage with [MyST-NB](https://myst-nb.readthedocs.io), avoid calling `Figure.show()` through [`ipywidgets.interactive_output()`](https://ipywidgets.readthedocs.io/en/stable/examples/Using%20Interact.html), because it causes the notebook to hang in some cycle (see CI for [ComPWA/compwa-org@d9240f1](https://github.com/ComPWA/compwa-org/pull/208/commits/d9240f1)). In the example below, the `update_plotly()` function is aborted if the notebook is run through Sphinx. "
]
},
{
Expand Down Expand Up @@ -515,9 +516,14 @@
" name=\"Surface\",\n",
")\n",
"plotly_fig = go.Figure(data=[plotly_surface])\n",
"plotly_fig.update_layout(height=500)\n",
"if STATIC_WEB_PAGE:\n",
" plotly_fig.show()\n",
"\n",
"\n",
"def update_plotly(a, b):\n",
" if STATIC_WEB_PAGE:\n",
" return\n",
" Z = numpy_function(X, Y, a, b)\n",
" camera_orientation = plotly_fig.layout.scene.camera\n",
" plotly_fig.update_traces(\n",
Expand Down

0 comments on commit 40a1d4c

Please sign in to comment.