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

Perfectly horizontal or vertical lines don't render to svg #991

Closed
amauboussin opened this issue Jul 8, 2012 · 13 comments
Closed

Perfectly horizontal or vertical lines don't render to svg #991

amauboussin opened this issue Jul 8, 2012 · 13 comments

Comments

@amauboussin
Copy link

Perfectly horizontal or vertical lines do not show up in svgs on my machine. Could be an issue with my specific setup, I am curious if anyone else can reproduce the issue.

Here is the code that causes the bug for me:

import pylab as plt
plt.plot([-1,1],[1,1]) #perfectly horizontal line does not render
plt.savefig('/Users/Andrew/Desktop/plot.svg', format='svg')

Here is a workaround I found:

import pylab as plt
plt.plot([-1,1],[1,1.001]) #not a perfectly horizontal line; renders
plt.savefig('/Users/Andrew/Desktop/plot.svg', format='svg')

My environment:
Matplotlib 1.10 on Mac OS X 10.7 obtained from Enthought

@pelson
Copy link
Member

pelson commented Jul 8, 2012

I get the same behaviour when viewing the svg produced in Safari on master. To help diagnosis, how are you viewing the produced SVG?

@amauboussin
Copy link
Author

I also viewed the SVG in Safari when I found the issue.
However, I just tried Inkscape and found the same line that does not render in Safari renders in Inkscape. So maybe it is a bug in safari?

@amauboussin
Copy link
Author

Another interesting thing to note: for the project I am doing I need to use zorder to put some things on top of others. When I export to svg and view in safari, the z order does not appear to have been followed and the wrong things are on top.When I export to png or view in Inkscape everything is in the right layer.

@WeatherGod
Copy link
Member

Most likely a bug in safari (a snapping issue, maybe?). I can view your example just fine in Firefox. Just curious, would setting a larger linewidth for the line make a difference in safari?

@mdboom
Copy link
Member

mdboom commented Jul 9, 2012

Probably a bug in WebKit, as it happens in Chrome, too:

http://code.google.com/p/chromium/issues/detail?id=135321

@pelson
Copy link
Member

pelson commented Aug 19, 2012

This is a problem upstream and there is no action for mpl as far as I can see. Should we document this somewhere? I've labelled it "doc", but if there is nothing to be done, we can close.

@amauboussin: Thanks for raising this, it is well worth knowing about!

@mdboom
Copy link
Member

mdboom commented Jan 27, 2014

Chrome 33 no longer seems to have this bug.

Safari 7 does.

@mdboom mdboom closed this as completed Jan 27, 2014
@pelson
Copy link
Member

pelson commented Jan 27, 2014

Closing - there is nothing for us to do here but wait for browsers to fix their bug.

@williamstein
Copy link

For what it is worth, I have different users (of SageMathCloud) who hit this bug constantly and report it to me. If any matplotlib experts had an idea for a workaround (even something horrible and crappy like slightly peturb the line), I would be interested... Even adding a link in this thread about how to complain to apple about this would be nice (?).

@slel
Copy link

slel commented Jul 30, 2015

One way to report bugs to Apple is to join their beta-tester program [1] and to test development versions of OS X. You get a "Feedback Assistant" app which lets you report bugs.

Last year I beta-tested OS X 10.10 Yosemite and I reported the Safari svg bug (horizontal and vertical lines not rendered) via the Feedback Assistant but that did not result in any fix.

I just re-enrolled to the beta-tester program for OS X 10.11 El Capitan and I'll report the bug again.

I created a page to display the bug [2]. Feel free to link to that page. Comments welcome.

[1] https://beta.apple.com/
[2] http://samuel.lelievre.free.fr/bug/safari-svg-bug-horizontal-vertical-line.html

@mdboom
Copy link
Member

mdboom commented Jul 30, 2015

@slel: Thanks.

As for workarounds: @williamstein's suggestion to slightly perturb the line is interesting. I suppose we should experiment with how much skew would be required and how badly that looks. The downside, of course, is that degrades the plot for everyone. (Unfortunately, I don't have access to a Mac this week to play -- anyone else is welcome to.)

We could attach a small amount of Javascript to the SVG that detects the browser and displays a warning (and a suggestion to switch to Chrome or Firefox) if it's one of the known broken browsers...

@slel
Copy link

slel commented Aug 3, 2015

The bug is fixed in WebKit. And thus in Safari 9.
This is confirmed by beta-testers of WebKit, of iOS 9, and of OS X 10.11 El Capitan.

@tacaswell
Copy link
Member

I am strongly 👎 on adding skew to work around bugs in external libraries.

Does this issue depend on line width?

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

No branches or pull requests

7 participants