-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Matplotlib: savefig produces incorrect SVG image for bar chart with log-scaled Y-axis #4341
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
Comments
90% this is a veiwer issue, not a MPL issue. |
True, but it does seem fairly trivial to fix, though. Just write out the On Wed, Apr 15, 2015 at 2:12 PM, Thomas A Caswell [email protected]
|
Yes. This is a long-known issue in librsvg-based viewers. The SVG spec @WeatherGod: Sorry, it's not a trivial fix because it means we have to go On Wed, Apr 15, 2015 at 2:12 PM Thomas A Caswell [email protected]
|
I just checked and this renders correctly in both chromium and firefox. |
@mdboom, forgive my ignorance on the particulars of the svg backend, but On Wed, Apr 15, 2015 at 2:16 PM, Michael Droettboom <
|
@mdboom Can you provide the part of the SVG specification that talks about the position of the clipping paths or |
@rsmith31415 http://www.w3.org/TR/SVG/struct.html#SVGElement It says the svg element may contain any number of any (of a long list) of elements types in any order. The section of defs http://www.w3.org/TR/SVG/struct.html#DefsElement says:
which we are doing (assuming I am understanding 'one of the ancestors' correctly to include the root node). I suspect that this is the reason that we emit all of the clip paths at the end. The clip urls are shared with in a figure (which is the correct thing to do). The first time we see each clip path it is generated and stashed for later re-use. If the Conversely, there is no other explicit requirement that it must come before so it is allowed to come after. It appears that this got reported upstream to ubuntu (https://bugs.launchpad.net/ubuntu/+source/librsvg/+bug/1207538) but was never bumped up to actual upstream (which I just fixed as https://bugzilla.gnome.org/show_bug.cgi?id=748565). I am closing this as this is pretty clearly a bug in librsvg as the svgs render correctly in:
there is nothing in the spec which says this can't be done, and there are major benefits to doing svg writing in a streaming fashion. The emitted svg render badly with 2 svg libraries (librsvg and libQtSvg)
due to upstream bugs. |
And the failure to render with |
@tacaswell Yes, I read that part and to be fair, it simply doesn't say anything about the position (which by omission, you might think that it shouldn't matter.) Maybe the confusion arises from the fact that virtually all examples of SVG code place The problem is that SVG is really important and this issue affects a sizable number of users, so it would be nice to have a solution, if possible of course. I'm not sure about the specifics, but wouldn't it be possible to read the SVG elements as you're already doing and before outputting the resulting element, move the |
@rsmith31415 and @tacaswell, I guess I'll just write a script to do it. It's far from ideal but is probably the best option at this point. It would be nice if there was a fix to matplotlib for this but doing so would violate the end-to-end principle, so maybe that's not the best approach. However, practically speaking, how long is going to take to get it fixed in librsvg and widely deployed? It seems like applying a workaround in Matplotlib is likely to solve the problem faster for Linux users, so that is the trade-off more or less. |
I have no idea how responsive the @abreslow If you want to make that a function to put into |
@abreslow Thanks! It would be great to have a workaround for this. |
It looks like librsvg 2.40.12 fixes this bug!!! That was a long time coming. Glad we stuck to our guns! The relevant entry in the librsvg CHANGELOG:
Benjamin Otte: beverage of your choice if I ever meet you. This is a big thing. |
See my stackoverflow post: http://stackoverflow.com/questions/29616764/matplotlib-savefig-produces-incorrect-svg-image-for-bar-chart-with-log-scaled-y
A potential solution to the issue is described here: ipython/ipython#8133 (comment)
The text was updated successfully, but these errors were encountered: