Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbconvert cannot deal with notebooks containing svg images #1863

Open
callegar opened this issue Sep 9, 2022 · 11 comments
Open

nbconvert cannot deal with notebooks containing svg images #1863

callegar opened this issue Sep 9, 2022 · 11 comments

Comments

@callegar
Copy link

callegar commented Sep 9, 2022

Description

If you use something like matplotlib_inline.backend_inline.set_matplotlib_formats('svg') then matplotlib produces images in the svg format. In many situations this is a good thing with respect to the image quality.

However, if you have this kind of images in the notebook, then nbconvert cannot deal with them.

Reproduce

  1. Create a cell with

    from matplotlib import pyplot as plt
    import matplotlib_inline
    matplotlib_inline.backend_inline.set_matplotlib_formats('svg')

    and evaluate it

  2. Create a cell with

    plt.plot([0,0],[1,1])

    and evaluate it

  3. Use jupyter nbconvert to convert the notebook to html.

  4. Open the html with a browser

Expected behavior

You should see a plot after point 2. above and then that should be also in the webpage seen at point 4. However at 4. you get a web page with no plot.

@goyodiaz
Copy link

goyodiaz commented Sep 12, 2022

Duplicate of #1849.

@carlosefr
Copy link

I'm also seeing this problem where SVG images are displayed as code instead of an image. The most recent version that works for me is nbconvert 6.5.2.

Later 6.5.x versions just display a blank area where the SVG should be, and 7.x versions up to 7.2.2 display the SVG as code.

nbconvert 7.2.3 (the latest version as I write this) works.

@carlosefr
Copy link

carlosefr commented Nov 2, 2022

I've done more tests and I now see that nbconvert 7.2.3 is still broken (e.g. SVG output from Plotly is rendered as a black rectangle) and the version that seems to work reliably is actuall nbconvert 6.5.0 (version 6.5.1 shows blank SVGs).

I'm testing with Jupyter Lab 3.4.8.

@carlosefr
Copy link

The commit that introduces the SVG issues is: 4b9c5e7

@carlosefr
Copy link

nbconvert 7.2.6 released yesterday still has the same problem (the black figures in the image below are embedded SVGs).

image

@carlosefr
Copy link

This is still an issue with nbconvert 7.2.7.

@carlosefr
Copy link

carlosefr commented Feb 27, 2023

With nbconvert 7.2.9 the output is better but still broken:
image

The test case by this bug report's OP is still obviously broken as well (the plot is missing the axis labels).
image

@carlosefr
Copy link

Is there a plan to fix this? I just tested nbconvert 7.4.0 and this is still an issue. With all the graphing toolkits using SVG, this is a relevant bug...

@jstorrs
Copy link
Contributor

jstorrs commented Jul 25, 2023

@carlosefr can you check if this is still an issue in nbconvert 7.7.x?

@carlosefr
Copy link

With nbconvert 7.7.2 I no longer see issues with the test cases that I have (above). I'll keep using this version and wil report if I find any issues, but it looks good. 👍

@aravindh-krishnamoorthy

See also a PR by me for explicitly included SVG images and LaTeX export here: #2190

However, PDF via LaTeX is still broken and has to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants