2

Is it possible? The code below illustrates what I want to do:

xdata = [0 1 2];
ydata = [0 1 0];
h = patch(xdata,ydata,'w');
set(h, 'FaceAlpha', 0.2);
print -dpng myfig

If I start MATLAB using option -nodisplay and run the code above, MATLAB simply gives me a core dump. I think that MATLAB should behave a bit better than crashing without further explanations, but I understand that this is due to the fact that neither the opengl nor the zbuffer renderers are available in terminal emulation mode.

I am getting around this problem by plotting the transparent figures in .svg format but this is not an ideal solution for me. My MATLAB scripts are generating HTML reports with many embedded figures and most browsers perform very poorly when rendering pages that contain several (relatively complex) .svg images. So, does anyone know of a better solution?

  • Possible duplicate: http://stackoverflow.com/questions/1853259/save-matlab-invisible-plot-under-terminal-as-an-image-with-same-size – Yamaneko Oct 23 '12 at 02:09
  • @VictorHugo not really. I have no problems to save/print invisible figures under terminal mode, as long as they do not contain any transparent element. It is the transparency issue what breaks MATLAB, i.e. if you remove the fourth line in my code everything works fine. – German Gomez-Herrero Oct 23 '12 at 10:17

1 Answers1

0

An indirect solution to this problem is to print the transparent figures to a .svg file using plot2svg(), and then use Inkscape to convert the .svg file to .png, .pdf or any other format supported by Inkscape. Inkscape offers quite good command line support so you can easily script the whole process from MATLAB. Inkscape is available in Windows, Linux and Mac OS X.