White line etching on exported .eps figures in R2014b

34 次查看(过去 30 天)
When I create a filled contour map in R2014b, export to a .eps file, and then use this in a PDF (for example importing into a PDF created by LaTeX, or just using the Linux command convert fig.eps fig.pdf), the image in the PDF is etched with white lines. When I create exactly the same figure and follow the same process (export to .eps, import or convert to PDF) in R2014a or earlier versions, the image quality is perfectly fine. The white lines mostly go away if I switch the renderer from painters to opengl, but then of course it's not a true vector graphic and the resulting image is grainy.
This problem occurs on both my school computer (Red Hat), my home computer (Ubuntu), and my friend's computer (Mac).
I can reproduce this problem with the following commands in R2014b:
z = peaks; v = [min(z(:)) -6:8]; contourf(z,v); colormap('jet');
print(gcf,'-depsc','-painters','R2014b_painters.eps');
Running the same commands in R2014a on the same computer, the image quality is fine and there are no white lines in the .eps or .pdf.

回答(4 个)

Elmar Plischke
Elmar Plischke 2016-8-11
Hi, updating to R2016a, I encountered also the 'white lines' problem when printing filled contours to eps.
I modified the prologue of the eps file, replacing
/f/fill ld
by
/f{GS 1 LW S GR fill}bd
moving the line a bit further down, so that GS LW GR are all defined. Now the path of the patch is not only filled but a small outline is drawn around it which fills the gaps.
  4 个评论
Elmar Plischke
Elmar Plischke 2018-1-16
In each eps file created, there is a section defining some shortcut postscript commands. This is the prologue.
I also replaced the xmlgraphics-commons.jar by compiling a version with a modified eps header, but gave it up due to version conflicts.
Jesper Pedersen
Jesper Pedersen 2018-3-27
Hi Elmar, thanks a lot for providing this fix. It works nicely.
My only problem is that it also seems to increase the fontweight of the axis labels in the figure. Any idea how to prevent this?

请先登录,再进行评论。


Jan Pecka
Jan Pecka 2017-6-14
编辑:Jan Pecka 2017-6-14
After a bit of research, I found this fix. It works great both for print() and hgexport(). https://github.com/Conclusio/matlab-epsclean

Jan
Jan 2014-12-28
编辑:Jan 2015-10-18
Many artifacts in PDFs are not caused by Matlab but by the settings of the PDF viewer. PDF is a 2D format and the smooth visualization of 3D patches requires tricks. So try to solve this inside the PDF viewer at first. See http://www.mathworks.com/matlabcentral/answers/15388-artifacts-in-figures-exported-as-pdf-from-matlab .
[EDITED] See this blog about the problems of polytopes intersecting in 3D.
  5 个评论
Sven
Sven 2016-2-18
Hi, I created a script to fix images like the one created with the command in the question. It is located here:
I hope it might help the Matlab developers to fix this problem (since the "bug" is present in literally every PDF viewer I tried) or that it might be of help to people who want to create nice EPS figures.
I thought I'd post it here because this was the first post I found when trying to find a solution.
Daniel
Daniel 2016-6-4
This might be a very late comment but I just ran into this issue after updating to a newer version of MATLAB.
Previous commenters are right, this is a bug in MATLAB's new renderer (HG2) which was introduced in MATLAB R2014b.
There is a very lengthy thread discussing this issue in export_fig's github: (GitHub - export_fig) Lines on Patch-Objects after *.EPS/PDF export - e.g. with contourf #44

请先登录,再进行评论。


Tobias Blatter
Tobias Blatter 2018-5-9
I'm using Linux and I solve the problem with:
  1. Export/Save Figure as a jpg file with appropriate dpi. I achieve good results with 700 dpi. But well, play around.
  2. Use convert and pdfcrop (optional) command from the ImageMagick suite.
convert input-file.jpg [options] output-file.pdf #jpg to pdf
pdfcrop output-file.pdf cropped-file.pdf #Tight borders

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by