From 6431a992edf407b4037e60de81d34fff064d1f4f Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 21 Feb 2024 15:23:49 +1100 Subject: [PATCH 1/5] TST: testing plotly --- lectures/_toc.yml | 1 + lectures/plotly.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lectures/plotly.md diff --git a/lectures/_toc.yml b/lectures/_toc.yml index a9e5b70e..b0820c7a 100644 --- a/lectures/_toc.yml +++ b/lectures/_toc.yml @@ -5,6 +5,7 @@ parts: numbered: true chapters: - file: about + - file: plotly - caption: Economic Data numbered: true chapters: diff --git a/lectures/plotly.md b/lectures/plotly.md new file mode 100644 index 00000000..adf401ed --- /dev/null +++ b/lectures/plotly.md @@ -0,0 +1,25 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# Plotly Example + +```{code-cell} ipython3 +!pip install plotly +``` + +An example plot + +```{code-cell} +# x and y given as array_like objects +import plotly.express as px +fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16]) +fig.show() +``` \ No newline at end of file From 2a93d4fc345ecd057ed1c27201d4069eb96f6279 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 21 Feb 2024 15:38:47 +1100 Subject: [PATCH 2/5] update config to see if alternative mime priorities are available --- lectures/_config.yml | 37 +++++++++++++++++++++++++++++++++++++ lectures/plotly.md | 12 +++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lectures/_config.yml b/lectures/_config.yml index ad95918c..2668f1d9 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -37,6 +37,41 @@ latex: sphinx: extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_exercise, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_proof, sphinx_tojupyter] config: + suppress_warnings: ["mystnb.unknown_mime_type"] + nb_mime_priority_overrides: [ + # HTML + ['html', 'application/vnd.plotly.v1+json', 9], + ['html', 'application/vnd.jupyter.widget-view+json', 10], + ['html', 'application/javascript', 20], + ['html', 'text/html', 30], + ['html', 'text/latex', 40], + ['html', 'image/svg+xml', 50], + ['html', 'image/png', 60], + ['html', 'image/jpeg', 70], + ['html', 'text/markdown', 80], + ['html', 'text/plain', 90], + # Jupyter Notebooks + ['jupyter', 'application/vnd.plotly.v1+json', 9], + ['jupyter', 'application/vnd.jupyter.widget-view+json', 10], + ['jupyter', 'application/javascript', 20], + ['jupyter', 'text/html', 30], + ['jupyter', 'text/latex', 40], + ['jupyter', 'image/svg+xml', 50], + ['jupyter', 'image/png', 60], + ['jupyter', 'image/jpeg', 70], + ['jupyter', 'text/markdown', 80], + ['jupyter', 'text/plain', 90], + # LaTeX + ['latex', 'text/latex', 10], + ['latex', 'application/pdf', 20], + ['latex', 'image/png', 30], + ['latex', 'image/jpeg', 40], + ['latex', 'text/markdown', 50], + ['latex', 'text/plain', 60], + ['latex', 'text/html', 70], + # Link Checker + ['linkcheck', 'text/plain', 10], + ] # false-positive links linkcheck_ignore: ['https://doi.org/https://doi.org/10.2307/1235116'] # myst-nb config @@ -44,6 +79,8 @@ sphinx: width: 80% nb_code_prompt_show: "Show {type}" # ------------- + html_js_files: + - https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js html_favicon: _static/lectures-favicon.ico html_theme: quantecon_book_theme html_static_path: ['_static'] diff --git a/lectures/plotly.md b/lectures/plotly.md index adf401ed..a7dc1d48 100644 --- a/lectures/plotly.md +++ b/lectures/plotly.md @@ -3,8 +3,10 @@ jupytext: text_representation: extension: .md format_name: myst + format_version: 0.13 + jupytext_version: 1.15.1 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 --- @@ -17,9 +19,13 @@ kernelspec: An example plot -```{code-cell} +```{code-cell} ipython3 # x and y given as array_like objects import plotly.express as px fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16]) fig.show() -``` \ No newline at end of file +``` + +```{code-cell} ipython3 + +``` From 08c77c927f13d1341a54ea6a46bb7c171622438e Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 21 Feb 2024 16:07:15 +1100 Subject: [PATCH 3/5] alternative short-term solution --- lectures/_config.yml | 2 ++ lectures/plotly.md | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lectures/_config.yml b/lectures/_config.yml index 2668f1d9..84f98523 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -69,6 +69,8 @@ sphinx: ['latex', 'text/markdown', 50], ['latex', 'text/plain', 60], ['latex', 'text/html', 70], + ['latex', 'application/vnd.plotly.v1+json', 80], + ['latex', 'application/vnd.jupyter.widget-view+json', 90], # Link Checker ['linkcheck', 'text/plain', 10], ] diff --git a/lectures/plotly.md b/lectures/plotly.md index a7dc1d48..6196bbf7 100644 --- a/lectures/plotly.md +++ b/lectures/plotly.md @@ -20,12 +20,19 @@ kernelspec: An example plot ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "A Plotly Scatter Plot" + name: plotlyfig +--- # x and y given as array_like objects import plotly.express as px fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16]) fig.show() ``` -```{code-cell} ipython3 -``` +```{only} latex +This figure is interactive you may [click here to see this figure on the website](https://intro.quantecon.org/plotly.html#plotlyfig) +``` \ No newline at end of file From f69417169e0501d32a6316e66c741cf8ca07f976 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 21 Feb 2024 16:51:11 +1100 Subject: [PATCH 4/5] only workable solution --- lectures/plotly.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lectures/plotly.md b/lectures/plotly.md index 6196bbf7..f3b34b36 100644 --- a/lectures/plotly.md +++ b/lectures/plotly.md @@ -19,20 +19,13 @@ kernelspec: An example plot +(plotlyfig)= ```{code-cell} ipython3 ---- -mystnb: - figure: - caption: "A Plotly Scatter Plot" - name: plotlyfig ---- -# x and y given as array_like objects import plotly.express as px fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16]) fig.show() ``` - ```{only} latex This figure is interactive you may [click here to see this figure on the website](https://intro.quantecon.org/plotly.html#plotlyfig) -``` \ No newline at end of file +``` From 71715a2f33ba65586bec1a143744162a4aff8ba7 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 21 Feb 2024 17:00:41 +1100 Subject: [PATCH 5/5] add ignore for builds --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e9c5e60..306b454c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: shell: bash -l {0} run: | rm -r _build/.doctrees - jb build lectures --path-output ./ -nW --keep-going + jb build lectures --path-output ./ - name: Upload Execution Reports (HTML) uses: actions/upload-artifact@v2 if: failure()