mirror of
https://github.com/TeachBooks/manual.git
synced 2026-11-12 22:35:51 +00:00
Update plotyl instructions
This commit is contained in:
parent
bd4516c25e
commit
025b2ff5c7
1 changed files with 52 additions and 0 deletions
|
|
@ -437,6 +437,58 @@
|
|||
"\n",
|
||||
"fig.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"If you want to create the plot during the build of the book, don't use `fig.show()` but use the code below:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython import get_ipython\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",
|
||||
" return HTML(fig.to_html(include_plotlyjs=\"cdn\"))\n",
|
||||
"\n",
|
||||
" # Local execution in Jupyter Notebook / JupyterLab / VS Code\n",
|
||||
" fig.show()\n",
|
||||
"\n",
|
||||
"....\n",
|
||||
"\n",
|
||||
"show_plotly(fig)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Make sure you have in your `_config.yml`:\n",
|
||||
"\n",
|
||||
"```yaml\n",
|
||||
"execute:\n",
|
||||
" execute_notebooks: \"auto\"\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Eventually in combination with [](../_git/github.com_TeachBooks_Sphinx-NB-Execution-Patterns/Manual/README.html)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue