-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ | |
"parametrizations", | ||
"pathlib", | ||
"permutate", | ||
"Plotly", | ||
"pyproject", | ||
"pytest", | ||
"PYTHONHASHSEED", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"hideCode": true, | ||
"hideOutput": true, | ||
"hidePrompt": true, | ||
"jupyter": { | ||
"source_hidden": true | ||
}, | ||
"slideshow": { | ||
"slide_type": "skip" | ||
}, | ||
"tags": [ | ||
"remove-cell" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%config InlineBackend.figure_formats = ['svg']\n", | ||
"import os\n", | ||
"\n", | ||
"STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"```{autolink-concat}\n", | ||
"```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"````{margin}\n", | ||
"```{spec} 3D plots with Plotly\n", | ||
":id: TR-023\n", | ||
":status: WIP\n", | ||
":tags: documentation; jupyter; sphinx\n", | ||
"\n", | ||
"Closes [ComPWA/compwa-org#206](https://github.com/ComPWA/compwa-org/issues/206).\n", | ||
"```\n", | ||
"````\n", | ||
"\n", | ||
"# 3D plots with Plotly\n", | ||
"<!-- cspell:ignore isomax isomin isosurface mgrid -->" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"tags": [ | ||
"remove-cell" | ||
] | ||
}, | ||
"source": [ | ||
"<!-- cspell:ignore cstride darkred labelpad matexpr rstride zorder -->" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"jupyter": { | ||
"source_hidden": true | ||
}, | ||
"tags": [ | ||
"remove-cell" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%pip install -q numpy==1.20.3 plotly==5.17.0" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This TR tests whether the HTML build of the TR notebooks supports [Plotly(https://plotly.com/python) figures. It's a follow-up to {need}`TR-006`, without the interactivity of `ipywidgets`, but with the better 3D rendering of Plotly. For more info on how Plotly figures can be embedded in Sphinx HTML builds, see [this page](https://myst-nb.readthedocs.io/en/v0.17.2/render/interactive.html#plotly) of MyST-NB (particularly the remark on [`html_js_files`](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_js_files).\n", | ||
"\n", | ||
"The following example is copied from [this tutorial](https://plotly.com/python/3d-isosurface-plots)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import plotly.graph_objects as go\n", | ||
"\n", | ||
"X, Y, Z = np.mgrid[-5:5:40j, -5:5:40j, -5:5:40j]\n", | ||
"ellipsoid = X * X * 0.5 + Y * Y + Z * Z * 2\n", | ||
"fig = go.Figure(\n", | ||
" data=go.Isosurface(\n", | ||
" x=X.flatten(),\n", | ||
" y=Y.flatten(),\n", | ||
" z=Z.flatten(),\n", | ||
" value=ellipsoid.flatten(),\n", | ||
" isomin=5,\n", | ||
" isomax=50,\n", | ||
" surface_fill=0.4,\n", | ||
" caps=dict(x_show=False, y_show=False),\n", | ||
" slices_z=dict(\n", | ||
" show=True,\n", | ||
" locations=[\n", | ||
" -1,\n", | ||
" -3,\n", | ||
" ],\n", | ||
" ),\n", | ||
" slices_y=dict(show=True, locations=[0]),\n", | ||
" )\n", | ||
")\n", | ||
"fig.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters