When starting MATLAB in batch mode without displaying (for example, when the $DISPLAY UNIX environment variable is disabled or when the matlab -nodisplay sign is started), you usually cannot use the opengl renderer tool. Instead, you should agree to render painters . For example:
>> print -dpng -opengl fig.png Warning: OpenGL mode can not be used in terminal emulation mode; ignoring option.
Unfortunately, painters often give poor results when working with 3D scenes with patches, lighting, transparency, etc. Here is one simple example (using display at the moment) where alpha is lost:
peaks alpha(0.5) print -dpng -opengl peaks_opengl.png print -dpng -painters peaks_painters.png

Due to these limitations, I was very happy to find the mostly undocumented MATLAB hardcopy() built-in function, which somehow allows the use of the opengl renderer without display. This function underlies the awesome export_fig() function. Now I can save high-quality 3D shapes in batch mode very quickly.
However, there is one catch: All text is lost when the shape passes through the hardcopy() function. For example:
plot(1,1) title('TEST')
>> A = hardcopy(gcf, '-Dopengl', '-r300'); Warning: Failed to draw text string > In /Applications/MATLAB_R2010b.app/toolbox/matlab/graphics/hardcopy.p>hardcopy at 21
The output indicator is completely devoid of any text (without a tick mark of the axis and without a name):
export_fig axis.png -opengl

So I'm wondering: How can I get the opengl handler to work with text in batch mode? Is there a way to make text work with hardcopy() function? Perhaps a way to rasterize the text in advance? Or a way to combine the painters hard copy of the text and the opengl hard copy of the plot? Alternatively, is there a completely different way to do this than the hardcopy() function? Also note that the problem is unlikely to be related to my system setup, as it plays on both Mac OS and Ubuntu.
John colby
source share