jupyter-book / jupyter-book

Create beautiful, publication-quality books and documents from computational content.
http://jupyterbook.org
BSD 3-Clause "New" or "Revised" License
3.88k stars 663 forks source link

ipympl outputs do not work #1053

Open Rahuketu86 opened 4 years ago

Rahuketu86 commented 4 years ago

I am unable to use ipympl with jupyterbook. Preliminary discovery suggests that we might need to include jupyter-matplotlib.js alongwith jupyterbook. However I am unable to find a cdn for same. Including this functionality here would be great addition

welcome[bot] commented 4 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

choldgraf commented 4 years ago

Yep - I believe you are correct that this is why it doesn't work. I think your best bet is to find this javascript library and attach it to your book via these instructions. You may want to message the ipympl developers to ask how you can access this.

Rahuketu86 commented 4 years ago

Alright this is my initial rendering for a page https://nlpbook.netlify.app/statistics/ipympl_primer

With my rudimentary knowledge of sphinx and js I have tried to add https://cdn.jsdelivr.net/npm/jupyter-matplotlib@0.7.4/dist/index.js

same as requirejs as described in faq with no success.

sphinx: config: html_js_files:

I will now contact ipyml developers and see if they respond

parmentelat commented 7 months ago

Hi folks - I'm running into this too

if I run jupyter-book to produce HTML from a notebook that does %matplotlib ipympl I get no plot at all in the output (and no relevant message in the browser console) see versions list below

After applying the recipe from https://github.com/agoose77/phd-thesis/blob/03d6392032e0066aa14e8c3a9a99de9f04762cdd/_config.yml#L185-L193 as provided by @agoose77 (thanks !) in https://github.com/executablebooks/jupyter-book/issues/1991 I get the plots indeed; they're not interactive as I would have expected (and as I think I remember we had working in the past at some point...), but at least they're there, which is a relief already :)

can be seen on a sample book here https://jupyterlab-examples.readthedocs.io/en/main/3-01-matplotlib-nb.html but again, before I adopted the config trick, I was not getting any plot at all

however all this looks terribly fragile.. and I'd hope to revive this issue so we can get a more robust solution for the long term ?

involved versions ``` $ pip show ipywidgets Version: 8.1.2 $ jupyter-book --version Jupyter Book : 1.0.0 External ToC : 1.0.1 MyST-Parser : 2.0.0 MyST-NB : 1.1.0 Sphinx Book Theme : 1.1.2 Jupyter-Cache : 1.0.0 NbClient : 0.10.0 ```