mirror of
https://github.com/TeachBooks/manual.git
synced 2026-11-12 22:35:51 +00:00
Update plotly HTML instructions
This commit is contained in:
parent
fca8533e97
commit
a639f14b94
1 changed files with 4 additions and 8 deletions
|
|
@ -32,16 +32,12 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython import get_ipython\n",
|
||||
"import os\n",
|
||||
"from IPython.display import HTML\n",
|
||||
"\n",
|
||||
"def show_plotly(fig):\n",
|
||||
" ip = get_ipython()\n",
|
||||
" if ip is None:\n",
|
||||
" return fig\n",
|
||||
"\n",
|
||||
" # Sphinx / Jupyter Book execution\n",
|
||||
" if \"sphinx\" in ip.config:\n",
|
||||
" # Use HTML when building book in CI environment\n",
|
||||
" if os.environ.get(\"CI\") == \"true\":\n",
|
||||
" return HTML(fig.to_html(include_plotlyjs=\"cdn\"))\n",
|
||||
"\n",
|
||||
" # Local execution in Jupyter Notebook / JupyterLab / VS Code\n",
|
||||
|
|
@ -70,7 +66,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"When using Plotly graphs, make sure the notebook is executed in Jupyter Lab / Jupyter Notebook for the figures to be shown in the book. Running the code in VS code might break the result in the book, although the output is visible in VS code. Alternatively, add the following lines of code to your notebook to have a valid output in the book as well:\n",
|
||||
"Alternatively, you can run the notebook locally before building the book. This is not recommended for the combination with git because you will be committing binary output to the repository. When pre-generating Plotly graphs, make sure the notebook is executed in Jupyter Lab / Jupyter Notebook for the figures to be shown in the book. Running the code in VS code might break the result in the book, although the output is visible in VS code. Add the following lines of code to your notebook to have a valid output in the book as well:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"import plotly.io as pio\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue