How can I avoid extra white lines when exporting a figure to a vector graphic?
Show older comments
I have a Matlab figure that looks great as a figure, but when I try to export it to a vector-based format (.eps or .pdf) white swirly lines appear as can be seen in the linked PDF. Some of the black dots also get partially covered, despite being much higher in the 3D graph than everything else, but that can be easily fixed in Inkscape.
I have also attempted to generate a .pdf or .eps using my preferred method, through "export_fig," but have ended up with the same results. Any tips would be much appreciated! The .fig file has also been attached.
9 Comments
Geoff Hayes
on 2 Jul 2014
Mark - I noticed the same swirly lines when saving your figure. Try changing the renderer of the current figure
open dye_distribution.fig
set(gcf, 'Renderer', 'OpenGL')
print -depsc dye_dist.eps
I did the above and then opened the eps file - the white swirly lines were gone. (This was on a Mac, R2014a). Try it and see what happens.
Geoff Hayes
on 2 Jul 2014
Mark's response since I deleted my answer which did not solve the problem.
Geoff,
using OpenGL definitely gets rid of the swirly white lines, however, I do not believe OpenGL can be used to create a vector-based image. Zooming in on the OpenGL version results in a very pixilated image.
Geoff Hayes
on 2 Jul 2014
You're right, Mark that is not what you want for the vector-based image. (I deleted my answer and pasted it as a comment instead.)
From this link http://www.mathworks.com/help/matlab/creating_plots/changing-a-figures-settings.html#f3-102410 there is only the Painters renderer which can be used for drawing the figure using vector graphics.
There is some code on the File Exchange ( http://www.mathworks.com/matlabcentral/fileexchange/43271-pcolor-eps-fix) that fixes a similar problem for when pcolor is used to generate the figure. I tried it on yours, and while it does remove some of the swirly lines, some other artefacts are introduced.
The only interest then may be why this problem is occurring and so may lead to you finding a workaround.
Philipp
on 25 Nov 2016
I have the same problem, any news on this issue? Thanks, Philipp
Abdullah
on 3 May 2024
did someone find a solution, since i have the same issue?
Josh
on 4 May 2024
dropping in on this... @Abdullah i downloaded the MATLAB figure from OP and saved as PDF, SVG, and EPS with no issue, i'm wondering if the issue lies with an older version of MATLAB or something more local to the machine?
if you can supply the figure(s) you're working with, i'd be happy to test on my machine
Saving directly from the GUI/figure did NOT produce the white lines (test.pdf)
Exporting via the command line with:
exportgraphics(fig,'testExport.pdf','ContentType','vector')
...did produce white lines (testExport.pdf)
not seeing the white lines in the figure though, they only showed up in the export (screenshot)
Can you confirm the process you're using? Also, not sure if it's just a difference beteween 2D and 3D plots, but the recent figure (3D) didn't include the same File menu dropdown options with the ability to Save As... EPS, SVG, etc. only image and PDF options
Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!