3

I want to save a figure in EPS format with:

saveas(gca, 'test.eps','epsc');

The figure is plotted with 'contourf' and a self-defined functions for plotting arrows. (I am using a package written by others, and I am not totally familiar with all of the code)

There are 3 cases when choosing different 'renderer's.

Case 1: When I use

set(gcf,'renderer','painters');

The EPS figure is incomplete, but 'clear' and with small size. Like Figure 1(converted to png): enter image description here

Case 2: When I use

set(gcf,'renderer','opengl');

or

 do not use any 'renderer'

the EPS figure is complete but blur, like figure 2: Figure 2

Case 3: When I use

set(gcf,'renderer','zbuffer');

or

set(findobj(gca,'type','patch'),'alphadatamap','none','facealpha',1); 

the EPS figure is both incomplete and blur.

'Incomplete' means the part outside the 'bell-shape' is missing.

'Blur' means the figure is kind of saw-toothed.

I use these 'renderer's according to the auther's notes (under 5.k).

Here is the question: how to make the EPS figure both complete and clear?

Eren
  • 159
  • 1
  • 12
  • 2
    I don't have a solution yet however the problem is almost certainly that only the opengl renderer supports transparency (i.e alpha ~=1) – RTL Jul 19 '14 at 17:38
  • Is it the problem with the software(Matlab), or the computer? Maybe I should try other versions of Matlab or run it on other machines... – Eren Jul 21 '14 at 02:36
  • Did you open the EPS files with a different viewer? In my experience different viewers show eps differently (sometimes). Make sure you view it under final production circumstances, i.e. if it is for a paper report print it on paper and see what it looks like. – EJG89 Jul 21 '14 at 07:15
  • I am not sure but this may be the problem with the opengl renderer (from mathworks homepage): `"OpenGL does not do colormap interpolation. If you create a surface or patch using indexed color and interpolated face or edge coloring, OpenGL interpolates the colors through the RGB color cube instead of through the colormap."` – patrik Jul 21 '14 at 08:36
  • Another thing, I have not tried the package, but are there any problems just saving the image as it is plotted the first time? Do you have to use a renderer? – patrik Jul 21 '14 at 08:42
  • I've tried the scripts on 'Windows 8 + Matlab R2010b', the situation is the same. (Now I am using OS X Mavericks + Matlab R2012b). – Eren Jul 22 '14 at 01:52
  • No, I open all of the EPS files with Preview (version 7.0). On windows 8, I opened all of them with SumatraPDF. I printed two of them, and they seem like the same with that shown on the screen. @EJG89 – Eren Jul 22 '14 at 04:57
  • Thank you for the information about OpenGL. :) I am totally innocent about that. @patrik – Eren Jul 22 '14 at 04:59
  • I've tried. I reopen Matlab, and run the script without using any 'renderer'. The situation is the same with that described 'Case 2'. @patrik – Eren Jul 22 '14 at 05:04
  • When I use 'opengl' or do not set renderer, the transparency is ok, but the figure is saw-toothed like Figure 2. @RTL – Eren Jul 22 '14 at 05:09
  • Just the clear up the 3 renderers: The better result for `painters` is because painters creates vector images (which also accounts for smaller size). However transparency isn't supported hence the missing sections. Not setting the renderer will use the default, which if there is transparency will be `OpenGL`, which is fine with the transparency but creates raster (pixel based) images which leads to the 'saw-toothed' (pixelated) curves. The bottom of the list is `zbuffer` which doesn't support transparency and creates raster images. – RTL Jul 22 '14 at 07:09
  • Thank you for the explanation. Now I am clear about the results for different renderers. It Seems like I can not get vector images with transparency... So should I try to plot with another software? Does matplotlib (Python) has such 'renderer' problem? @RTL – Eren Jul 24 '14 at 02:14
  • @leftriver I honestly don't know about other packages. If you are on a fairly recent version of Matlab then there is an undocumented fix for line smoothing of non standard line widths, which can vastly improve the results with openGL. try `set(findobj('type','patch'),'LineSmoothing','on');` – RTL Jul 24 '14 at 07:39
  • @RTL I've tried, but the result looks like the same with Figure 2. Thank you anyway. – Eren Jul 26 '14 at 15:00

1 Answers1

0

As @RTL mentions, the problem with cases (1) and (3) is that you are using a transparent patch (the 'cone of influence' in your wavelet analysis) and neither painters nor zbuffer support transparency (zbuffer has been removed in more recent versions of Matlab). MatLab will automatically switch to opengl as the figure renderer if you change the alpha value (transparency) on any object.

Now, as for the blur, you might be able to solve that by setting the 'GraphicsSmoothing' option to 'off' (see the matlab documentation on this), but this option is only available from 2014b onwards. Alternatively, you can check this related question in Stack Overflow.

Finally, if you have a good vector editing program (say, Illustrator), you can just export the painters-rendered EPS file (a PDF will also work) from Matlab, and use an external editor to make the cone of influence semi-transparent (you will find the contour is intact behind it in the EPS). Even less work: use a line to delineate the cone of influence instead of a patch.

Community
  • 1
  • 1
Carlos
  • 318
  • 2
  • 11