MATLAB Answers

Bug eps, pdf matlab 2014b surface plot (contourf)

14 views (last 30 days)
Hi all, with matlabR2014b I got very bad quality eps and pdf files for surface plots.
)
But using the same script with MatlabR2014b I got very bad quality figures (white lines, bad dot size using plot3D, and very large size for the file: the eps from R2014b is 40x larger than the eps from R2014a!): http://lhoupert.fr/files/others/matlab/bugfig2014b/figR2014b.eps and http://lhoupert.fr/files/others/matlab/bugfig2014b/figR2014b.pdf <http://lhoupert.fr/files/others/matlab/bugfig2014b/figR2014b.pdf>
Do you know if this bug is fixed / will be fixed in the more recent versions of Matlab (>=R2015a)?

  0 Comments

Sign in to comment.

Accepted Answer

Steve Eddins
Steve Eddins on 9 Sep 2015
Hi Loïc,
Prior to R2014b, the MATLAB graphics system used a different process, with a different set of vector primitives, for exporting to vector formats such as EPS and PDF. Unfortunately, these primitives could not always render every aspect of a MATLAB figure correctly. Also, other software, such as printer drivers, often had bugs in rendering these primitives. As a result, there were many reports of incorrect exported plots in earlier versions of MATLAB.
To solve these problems, the MATLAB graphics team revised the rendering pipeline to obtain more direct control over the vector output. The primary method was to use many small triangles. This procedure corrected earlier problems but had two undesirable effects:
  • It increased the output file size.
  • It caused white lines to appear when viewing the PDF or EPS files on screen. (The white lines do not affect printed output.)
The file size increased directly as a result of the increased number of primitives (small triangles).
The white lines are caused by bugs in widely-used PDF and EPS viewers. The antialiasing method in these viewers does not handle correctly the case where two same-color polygons share a common edge. The white lines are appearing at these common edges.
Compensating for bugs in external viewers has proved challenging, but MATLAB R2015a has improved the situation somewhat by grouping triangle strips together. A graphics developer who looked at your plots thinks that you will see improvement in the visual quality and file size with R2015a, although the problems might not be solved completely.

  1 Comment

Ilja Maljutenko
Ilja Maljutenko on 11 Jul 2016
If one wants his graphics to consist of numerous primitive elements, one chooses raster format and adjusts resolution. The purpose of vector graphics is different.
  • Increase in output file size is inevitable, since same characteristics are saved for each so called primitive. For even plot(0:0.01:pi,sin(0:0.01:pi));print(gcf,'-depsc','-painters','sin_test.eps') line is saved into 7 different line segments. I have no idea why is that necessary.
  • Pseudo lines is just empty space between artificially sliced patches. They are there with reason and no antializing should make it look prettier.
With those new features matlab vector graphics have made postprocssing nearly impossible and hardly publishable in science journals.

Sign in to comment.

More Answers (3)

Loïc Houpert
Loïc Houpert on 4 Jun 2015
All the files are in a vectorial format. Before printing the figure, I do: set(gcf, 'renderer','painters'). And I launch exactly the same script with the 2 Matlab versions.
If the pdf or eps files are opened with a software like Inkscape, you can see that is vector format.
It's seems that in MatlabR2014b, the contourf surface is composed of small triangle, like with the surf function. But in MatlabR2014a, the contourf surfaces were unique vector ''objects''
PS: I am using the unix Version of Matlab

  0 Comments

Sign in to comment.


Loïc Houpert
Loïc Houpert on 15 Jun 2016
Are you planning to add a possibility in the new release of matlab to go back in the graphical function prior R2014b? It's a shame to not be able to export nice vectorial plots since R2014b. I just re-used Matlab R2008 to do a figure for a scientific paper even if I have R2014b and R2016a on my computer.....

  1 Comment

Walter Roberson
Walter Roberson on 15 Jun 2016
Only Mathworks Sales is authorized to speak about product plans.

Sign in to comment.


Jan
Jan on 4 Jun 2015
I guess that the renderer is set to OpenGL automatically, such that the created EPS/PDF contains pixels graphics instead of the smarter and sarper vector format. Please try to set the renderer to Painters manually.

  0 Comments

Sign in to comment.

Sign in to answer this question.