matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.59k stars 225 forks source link

Export with `nbconvert` to PDF only shows figures with `display(fig)` [ipympl-0.8.2] #403

Closed tovrstra closed 2 years ago

tovrstra commented 2 years ago

Describe the issue

When exporting the example notebook as follows, most figures are not shown, except the one with display(fig):

git clone git@github.com:matplotlib/ipympl.git
cd ipympl/examples/
jupyter nbconvert --execute --to pdf ipympl.ipynb

output:

[NbConvertApp] Converting notebook ipympl.ipynb to pdf
[NbConvertApp] Writing 86647 bytes to ipympl.pdf

PDF generated with 0.8.2: ipympl.pdf

This worked better in ipympl-0.8.0, but no longer works in 0.8.1 nor 0.8.2. For reference, this is the PDF generated with ipympl 0.8.0: ipympl.pdf

I believe PR #380 broke this, but I'm not sure. I also cannot judge if this is an ipympl issue, or rather a problem with nbconvert?

Versions

 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) 
[GCC 9.4.0]
ipympl version: 0.8.2
Selected Jupyter core packages...
IPython          : 7.30.1
ipykernel        : 6.6.0
ipywidgets       : 7.6.5
jupyter_client   : 6.1.12
jupyter_core     : 4.9.1
jupyter_server   : 1.13.1
jupyterlab       : 3.2.5
nbclient         : 0.5.9
nbconvert        : 6.3.0
nbformat         : 5.1.3
notebook         : 6.4.6
qtconsole        : not installed
traitlets        : 5.1.1
Known nbextensions:
  config dir: /home/toon/.jupyter/nbconfig
    notebook section
      splitcell/splitcell disabled
      nbextensions_configurator/config_menu/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/config_menu/main
      contrib_nbextensions_help_item/main  enabled 
      - Validating: OK
      spellchecker/main  enabled 
      - Validating: OK
      toc2/main  enabled 
      - Validating: OK
      k3d/extension  enabled 
      - Validating: OK
    tree section
      nbextensions_configurator/tree_tab/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/tree_tab/main
  config dir: /home/toon/.local/etc/jupyter/nbconfig
    notebook section
      nbdime/index  enabled 
      - Validating: problems found:
        - require?  X nbdime/index
      rise/main  enabled 
      - Validating: OK
  config dir: /home/toon/miniconda3/envs/py4sci/etc/jupyter/nbconfig
    notebook section
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      rise/main  enabled 
      - Validating: OK
      voila/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      nbextensions_configurator/config_menu/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/config_menu/main
      contrib_nbextensions_help_item/main  enabled 
      - Validating: OK
    tree section
      nbextensions_configurator/tree_tab/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/tree_tab/main
  config dir: /etc/jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
JupyterLab v3.2.5
/home/toon/miniconda3/envs/py4sci/share/jupyter/labextensions
        jupyter-matplotlib v0.10.2 enabled OK
        k3d v2.11.0 enabled OK (python, k3d)
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)
        @ijmbarr/jupyterlab_spellchecker v0.7.2 enabled OK (python, jupyterlab-spellchecker)
        @ryantam626/jupyterlab_code_formatter v1.4.10 enabled OK (python, jupyterlab-code-formatter)
        @voila-dashboards/jupyterlab-preview v2.1.0 enabled OK (python, voila)
martinRenou commented 2 years ago

Thanks for opening an issue.

This worked better in ipympl-0.8.0

I am really surprised by this. I will investigate on this.

martinRenou commented 2 years ago

You were right in saying 46a955fec6bc8c80c4b253d6f1cd64419eb35292 is the culprit here. Doing some more investigation.