Problem with patch transparency (FaceAlpha)

徘徊边缘 提交于 2019-12-10 15:46:07

问题


I encountered some strange problem with patch ploting in Matlab 2010b with windows xp.
When I try to plot following patch, I get a patch which is not all-filled, but has some blank parts.

This can be solve if I set the renderer to 'painters' (see below),
but then I can't change the transparency of the patch.
Has anyone encountered similar problem before? any workaround?

x = [734608.791666667;734608.843750000;734609;734609.041666667;734609.086805556;734609.125000000;734609.250000000;734609.277777778;];
y = [85.7847149493030;95.4499999983124;96.4800000077516;112.549999984098;109.949999996456;118.299999970804;120.450000002981;112.600000008944;];

figure;
set(gcf, 'Renderer', 'opengl');
patch(x, y, 'r');
title('this plot is with wrong vertices positions');

figure;
set(gcf, 'Renderer', 'painters');
patch(x, y, 'r', 'FaceAlpha', 0.1);
title('this plot is OK, but renderer ignores the transparency');

figure;
set(gcf, 'Renderer', 'opengl');
patch(x, y, 'r', 'FaceAlpha', 0.1);
title('this plot is with wrong vertices positions, but with transparency');

回答1:


The problem seems to originate from the floating point accuracy somewhere the MATLAB -> OpenGL rendering pipeline (my guess).

If you manipulate x to:

x = [734608.791666667;734608.843750000;734609;734609.041666667;734609.086805556;734609.125000000;734609.250000000;734609.277777778;];
x = (x - mean(x));

The plots seem to work fine.



来源:https://stackoverflow.com/questions/7318156/problem-with-patch-transparency-facealpha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!