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?
An indirect solution to this problem is to print the transparent figures to a
.svgfile using plot2svg(), and then use Inkscape to convert the.svgfile to.png,.pdfor 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.