MATLAB: Is it that when I create patches using the opengl renderer in MATLAB 7.7 (R2008b), the data plotted is incorrect

coarsefloatfloatinggridMATLABopenglpatchesprecisionrenderer

When I use OpenGL renderer to create patches in MATLAB 7.7 (R2008b) the data is plotted incorrectly, wheras when I use another renderer such as Painter or ZBuffer, the data is accurate.
Reproduction Code:
This gives the incorrect result:
figure
set(gcf,'renderer','opengl');
p2 = patch([500000.99 500001 500001 500000.99],[0.8 0.8 1.2 1.2],'r');
xlim([500000.99-.05 500001+.05])
This gives the correct result:
figure
set(gcf,'renderer','painters');
p2 = patch([500000.99 500001 500001 500000.99],[0.8 0.8 1.2 1.2],'r');
xlim([500000.99-.05 500001+.05])

Best Answer

The OpenGL renderer uses only single precision. As a result, and the numbers that are being plotted are not able to be resolved using OpenGL. The Painters and ZBuffer renderers use double precision, so, unit differences between numbers on the order of 1e7 are able to be resolved. This becomes especially relevant when using data input such as dates and trying to resolve hours.