4

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');
shahar_m
  • 3,461
  • 5
  • 41
  • 61
  • +1 very bizarre indeed. I wonder if it is also reproducible on Mac/Linux (you should maybe file this as a bug to MathWorks) – Amro Sep 07 '11 at 04:10

1 Answers1

4

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.

upperBound
  • 680
  • 4
  • 11
  • working indeed. Since the x values are actually datenums, I use x = x-floor(min(x)) instead. Thanks! – shahar_m Sep 11 '11 at 10:52