White line etching on exported .eps figures in R2014b

35 Ansichten (letzte 30 Tage)
Jennifer
Jennifer am 11 Dez. 2014
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.

Antworten (4)

Elmar Plischke
Elmar Plischke am 11 Aug. 2016
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 Kommentare
Elmar Plischke
Elmar Plischke am 16 Jan. 2018
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 am 27 Mär. 2018
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?

Melden Sie sich an, um zu kommentieren.


Jan Pecka
Jan Pecka am 14 Jun. 2017
Bearbeitet: Jan Pecka am 14 Jun. 2017
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 am 28 Dez. 2014
Bearbeitet: Jan am 18 Okt. 2015
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 Kommentare
Sven
Sven am 18 Feb. 2016
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 am 4 Jun. 2016
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

Melden Sie sich an, um zu kommentieren.


Tobias Blatter
Tobias Blatter am 9 Mai 2018
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

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by