Clear Filters
Clear Filters

White line etching on exported .eps figures in R2014b

29 views (last 30 days)
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');
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.

Answers (4)

Elmar Plischke
Elmar Plischke on 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
/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.
Elmar Plischke
Elmar Plischke on 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 on 27 Mar 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?

Sign in to comment.

Jan Pecka
Jan Pecka on 14 Jun 2017
Edited: Jan Pecka on 14 Jun 2017
After a bit of research, I found this fix. It works great both for print() and hgexport().

Jan on 28 Dec 2014
Edited: Jan on 18 Oct 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 .
[EDITED] See this blog about the problems of polytopes intersecting in 3D.
Sven on 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 on 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

Sign in to comment.

Tobias Blatter
Tobias Blatter on 9 May 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


Community Treasure Hunt

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

Start Hunting!