Open akdor1154 opened 5 years ago
Spyder's SVG renderer does not support SVG features that are used by matplotlib.
We're limited to what QtSvg can render, so there's nothing else we can do about it.
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...
That's planned work for Spyder 5.
@ccordoba12 would you accept a dependency on libresvg? It's a reasonably standalone (i.e. doesn't need to pull in Cairo) Rust SVG library. I can probably create Python bindings + prebuilt wheels for it if Spyder would consider using it.
I think you'll need to add it to qtconsole because we're not in charge of rendering plots directly. We just receive what qtconsole send us and display it in the Plots pane.
Besides, I don't understand how the interaction between that library and Qt would work.
I think you'll need to add it to qtconsole because we're not in charge of rendering plots directly. We just receive what qtconsole send us and display it in the Plots pane.
Besides, I don't understand how the interaction between that library and Qt would work.
If we had access to such a package, I could most likely use it to render svg plots in the Plots pane instead of using the QSvgRenderer
, which as you mentioned is limited.
In the Plot pane, we always paint a bitmap on a widget, whether we receive a png, jpeg or svg from the console, i.e. that we always use the QPainter.drawPixmap
method. So the QSvgRenderer
is only used to pre-convert and pre-scale the svg string that we receive from the console into a QImage
before painting it. We do not use it to paint the image on the widget from the svg data directly. So, I'm pretty sure we could use anoter svg renderer to do the conversion and render svg plots in the Plots pane.
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.
For future references, here is a link to the resvg repository on github : https://github.com/RazrFalcon/resvg
And here is an interesting article about the library : http://libregraphicsworld.org/blog/entry/introducing-libresvg
Hi, is this still planned for v5?
We'll try to add it in the next three to six months to Spyder 5.
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)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.
)
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
Dependencies