MATLAB: When I use COLORBAR, why do I get a warning about RGB color data and the painters renderer

MATLAB

I define a volume, and store the face and vertex structure to a variable. I then pass this structure into a function that creates a patch to draw the volume and adds a colorbar. The call to COLORBAR results in the following warning:
Warning: RGB color data not yet supported in Painter's mode.
> In D:\Applications\MATLABR12p1\toolbox\matlab\graph3d\colorbar.m at line 254
In e:\837941\display_current_density.m at line 60
Warning: RGB color data not yet supported in Painter's mode.
> In D:\Applications\MATLABR12p1\toolbox\matlab\graph3d\colorbar.m at line 254
In e:\837941\display_current_density.m at line 60
Warning: RGB color data not yet supported in Painter's mode.
> In D:\Applications\MATLABR12p1\toolbox\matlab\graph3d\colorbar.m at line 347
In e:\837941\display_current_density.m at line 60
Warning: RGB color data not yet supported in Painter's mode.
> In D:\Applications\MATLABR12p1\toolbox\matlab\graph3d\colorbar.m at line 347
In e:\837941\display_current_density.m at line 60

Best Answer

This is a problem in MATLAB 6.1 (R12.1).
As a workaround, you can place a DRAWNOW command before adding the colorbar:
drawnow;
colorbar;
Most likely, the problem is that the figure's default renderer is 'painters', but the color data requires a different renderer to draw your patch. MATLAB chooses to set the renderer at an appropriate time, and in this case (inside of a function), it decides to choose the renderer after all the drawing commands are executed so it only has to flush its graphics queue once. Since the colorbar is being added before the graphics queue is flushed, and hence before the figure knows that it should have changed its renderer, you encounter the warning. The DRAWNOW command solves the problem because it forces the graphics queue to flush.