How to remove white lines when surf edgecolor is set to 'none' and figure is exported as a .pdf file using export_fig?

3 次查看(过去 30 天)
I wish to properly plot and export a figure of a surface plotted using
surf
First, I wanted to remove the edges of its related mesh. To that end, I used
set(h,'edgecolor','none')
Then, I wanted to use a specific LaTeX-like font. To that end, I used
set(gca,'FontName','CMU Serif')
and, for instance,
ylabel('$$\varepsilon$$','Interpreter','latex')
Now, the figure as it is displayed on the screen is exactly as I want it to be:
But here comes the tricky part. I want to export the figure as a .pdf file, exactly as it is displayed on the screen. To that end, I tried to use export_fig:
export_fig filename -Transparent -pdf
but I keep getting these white lines on the edges:
Someone could help me getting rid of them, please?

采纳的回答

Jan
Jan 2018-4-24
编辑:Jan 2018-4-24
In this forum you find many questions concerning these white lines on PDF. Under some of them you find my answer, that this is not a problem of Matlab, but of the program, which displays the PDF. If it is Acrobat reader, open the Preferences and deselect "Smooth line art" and/or "smooth images".
It is an inherent problem: If two triangles with different colors are touching, it cannot be uniquely defined, how the pixels on the edge are drawn. The decision to apply an anti-aliasing, "smoothing", causes the edge to be a mixture of the color of the area and background of the paper. If both triangles use this, you see the white color of the background at the edge. Disabling the smoothing let this effect vanish. This is a problem of the definition of surfaces as 2D vector graphics in the PDF format.
Maybe it is better to use the OpenGL renderer and export this as a bitmap instead of vector graphics. See e.g. print -dpng. You can set a higher resolution there also e.g. by -r 600, if you are afraid for pixel artifacts in the output.
  1 个评论
Sofia
Sofia 2018-4-24

Thank you for your answer!

Since it seems to be a problem of the program displaying the pdf, I will try to look for a solution over there.

I did saw your answers to other similar questions, however, I'm restricted to send the figure as a pdf file. Also, sometimes I lost the CMU font while using print.

请先登录,再进行评论。

更多回答(0 个)

类别

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