This warning is documented behavior of the painters renderer.
To work around the issue, first store the surface's CData to a variable. Then use the RGB2IND function to convert the RGB CData color array to an indexed color array with a colormap. Finally set the surfaces's CData property to the array of indexed colors and apply the colormap to the figure. For example:
s = surf(peaks(50), 'CData', cat(3, 0.8*ones(50), ones(50), 0.65*ones(50)));
rgb_colors = get(s, 'CData');
[i, map] = rgb2ind(rgb_colors, 64);
set(s, 'CData', double(i));
colormap(map);
Note that in R2008b and earlier RGB2IND was included in the Image Processing Toolbox. Starting with R2009a, RGB2IND is included as a core MATLAB function.
The same warning message can also occur in other scenarios where RGB CData is used. For instance the warning will be generated if a figure generated using HIST3 (from the Statistics Toolbox) is copied to the clipboard or printed using the painters renderer. In that case, the same workaround as above applies once you have a handle to the surface generated by HIST3 which can be found using the FINDOBJ function.
hist3(rand(100,2))
s = findobj('Type', 'surface')
Best Answer