Reputation: 5595
I'm using 64 bit matlab r2010a on windows 7 (this may be relevant if this is an obscure rendering bug)
this is apparently a bizarre bug that manifests itself when the text interpreter is latex
set(0, 'DefaultTextInterpreter', 'Latex');
this code will produce a blue box with a black border and a legend outside the axes
cla reset;
patch ([0.5 0.5 0.75 0.75 0.5], [0.5 0.75 0.75 0.5 0.5], 'b', 'FaceAlpha',1);
xlim([0 1]);
ylim([0 1])
legend ('blah', 'Location', 'bestOutside')
If I change the code, so that the patch has a non-opaque alpha value,
cla reset;
patch ([0.5 0.5 0.75 0.75 0.5], [0.5 0.75 0.75 0.5 0.5], 'b', 'FaceAlpha',0.5);
xlim([0 1]);
ylim([0 1]);
legend ('blah', 'Location', 'bestOutside')
I get an empty black box instead of a filled one, and an axes resized correctly to place a legend outside but no legend.
The patch also disappears if I run all the code up to legend, then click "edit plot" on the figure menu. The patch does not reappear after I uncheck "edit plot". The figure and axes properties (using get(gcf) and get(gca) respectively) are identical before and after clicking and unclicking "edit plot"
Resizing the figure window does not cause the patch to disappear. Resizing the axes from the command line:
p = get(gca, 'Position');p(3) = p(3)/2;set (gca, 'Position', p)
does not cause the patch to dissapear.
I have tried setting opengl to hardware and software mode (using opengl hardware, opengl software) and found no difference.
Upvotes: 3
Views: 2792
Reputation: 5595
Thanks to rasman for trying to reproduce the bug and failing. This helped me figure out that the problem is an interaction between the latex intepreter and openGL. This is apparently related to MATLAB bug 359330
The solution is to set the text properties of objects individually rather than using the default rendering option (which is a pain)
Summary
Setting the defaultTextInterpreter figure property to 'latex' with OpenGL can cause MATLAB to SEGV or assert when printing to PostScript Description
When using the OpenGL renderer, setting a figure's defaultTextInterpreter property to 'latex' and then printing to PostScript or encapsulated PostScript can cause a crash or an assert in MATLAB. For example, this code,
figure;
axes;
set(gcf,'defaultTextInterpreter','latex');
set(gcf,'renderer','openGL');
print figure.eps;
could generate a crash or an assertion. At other times, the following errors could appear in the MATLAB command window:
??? Error using ==> strcat Not enough input arguments.
Error in ==> tex>localCheckValidString at 138 strchk = strcat(str{:});
Error in ==> tex at 111 [err] = localCheckValidString(str);
Workaround
Do not set the defaultTextInterpreter property to 'latex' when using OpenGL. Rather, set the Interpreter property of text objects to 'latex' individually.
Upvotes: 3