question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVG renderer does not properly render matplotlib plots

See original GitHub issue

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

Spyder’s SVG renderer does not support SVG features that are used by matplotlib.

What steps reproduce the problem?

  1. run %config InlineBackend.figure_formats = ['svg']

  2. Render the following plot with matplotlib: Screenshot_2019-08-09_12-19-32 (as rendered by Ristretto on my machine) example.svg.txt (matplotlib’s svg output, sorry github doesn’t accept direct svg uploads)

(sorry I don’t have a MRE, but it uses hatching, .e.g.

    ax.fill_between(
        summarySNS['Date'],
        summarySNS['lowBoundary'],
        summarySNS['highBoundary'],
        facecolor="none",
        edgecolor=getFillColour(color, dl=+0.2, ds=-0.1),
        hatch='//////'
    )

)

  1. Observe that spyder renders it as Screenshot_2019-08-09_11-54-17

What is the expected output? What do you see instead?

The expected output would be the SVG properly rendered, at it would be by a browser.

To be honest I’d love to see you use QWebEngine to display it - that way interactive SVG with Javascript could work as well, and it would be a gateway to displaying plot libraries that output as ipython html widgets…

Versions

  • Spyder version: 4.0b4
  • Python version: 3.7.3 x64
  • Qt version: 5.12.2
  • PyQt version: 5.12.1
  • Operating System name/version: Ubuntu 19.04

Dependencies

pygments >=2.0    :  2.3.1 (OK)
qdarkstyle >=2.6.4:  2.7 (OK)
sphinx >=0.6.6    :  2.1.2 (OK)
psutil >=0.3      :  5.5.1 (OK)
pyls >=0.27.0     :  v0.28.1 (OK)
nbconvert >=4.0   :  5.4.0 (OK)
pandas >=0.13.1   :  0.25.0 (OK)
numpy >=1.7       :  1.16.2 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.5.2 :  4.5.2 (OK)
IPython >=4.0     :  5.8.0 (OK)
matplotlib >=2.0.0:  3.0.2 (OK)
pylint >=0.25     :  2.2.2 (OK)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Apr 6, 2021

We’ll try to add it in the next three to six months to Spyder 5.

1reaction
ccordoba12commented, Feb 28, 2020

Thanks a lot for letting us know about this @jnsebgosselin! This is certainly something doable and it’d be a great improvement for Spyder 5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyQt5 QWebView not rendering matplotlib svg properly
I'm trying to use QWebView to display an html page containing several matplotlib generated svg files. The content displays as I would expect ......
Read more >
What is the best way to include matplotlib plots? - TeX
It seems to me there is no state-of-the-art solution. ... I will offer some tips on how to make the best of LaTeX...
Read more >
What's new in matplotlib — Matplotlib 1.5.1 documentation
Vector file formats (pdf, ps, svg) are efficient for many types of plot element, but for some they can yield excessive file size...
Read more >
Displaying Altair Charts — Altair 4.2.0 documentation
Optionally, for offline rendering in JupyterLab, you can use the mimetype ... to render plots from another Python interface that does not have...
Read more >
Exporting Matplotlib Plots to LaTeX – Timo Denk's Blog
The solution to all four problems is exporting a PGF file from matplotlib, so LaTeX itself can take care of rendering the figure....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found