MATLAB:当faceAlpha不为1时,补丁在各种情况下消失
我在 Windows 7 上使用 64 位 matlab r2010a (如果这是一个不起眼的渲染错误,这可能是相关的)
这显然是一个奇怪的错误,当文本解释器是乳胶时,
set(0, 'DefaultTextInterpreter', 'Latex');
此代码将产生一个带有黑色边框的蓝色框和轴外的图例
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')
如果我更改代码,使补丁具有非不透明的 alpha 值,
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')
我会得到一个空的黑框而不是填充的黑框,并且轴的大小正确调整以在外部放置图例,但没有图例。
如果我运行所有代码直至图例,然后单击图形菜单上的“编辑图”,该补丁也会消失。取消选中“编辑绘图”后,该补丁不会重新出现。在单击和取消单击“编辑图”之前和之后,图形和轴属性(分别使用 get(gcf) 和 get(gca))是相同的
调整图形窗口大小不会导致补丁消失。从命令行调整轴的大小:
p = get(gca, 'Position');p(3) = p(3)/2;set (gca, 'Position', p)
不会导致补丁消失。
我尝试将opengl设置为硬件和软件模式(使用opengl硬件,opengl软件),没有发现任何区别。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢 rasman 尝试重现该错误但失败了。这帮助我弄清楚问题是 Latex 解释器和 openGL 之间的交互。这显然与 MATLAB bug 359330
解决方案是单独设置对象的文本属性,而不是使用默认的渲染选项(这很
痛苦
)使用 OpenGL 将 defaultTextInterpreter 图属性设置为“latex”可能会导致 MATLAB 在打印到 PostScript 时进行 SEGV 或断言
说明
使用 OpenGL 渲染器时,将图窗的 defaultTextInterpreter 属性设置为“latex”,然后打印到 PostScript 或封装的 PostScript 可能会导致 MATLAB 中崩溃或断言。例如,此代码
可能会生成崩溃或断言。有时,MATLAB 命令窗口中可能会出现以下错误:
解决方法
使用 OpenGL 时,请勿将 defaultTextInterpreter 属性设置为“latex”。相反,将文本对象的 Interpreter 属性单独设置为“latex”。
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,
could generate a crash or an assertion. At other times, the following errors could appear in the MATLAB command window:
Workaround
Do not set the defaultTextInterpreter property to 'latex' when using OpenGL. Rather, set the Interpreter property of text objects to 'latex' individually.