SVG renderer does not properly render matplotlib plots
See original GitHub issueIssue 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
(orpip
, 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?
-
run
%config InlineBackend.figure_formats = ['svg']
-
Render the following plot with matplotlib: (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='//////'
)
)
- Observe that spyder renders it as
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:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ll try to add it in the next three to six months to Spyder 5.
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.