How can I export a figure containing a surface with RGB CData to an eps file using the painters renderer in MATLAB 7.6 (R2008a)?

5 views (last 30 days)
I have a figure which contains a surface object. The surface's CData property is set to an m-by-n-by-3 array of RGB colors. When I try to export the figure using the command
print -depsc -painters myEpsFile
I get the warning message
Warning: RGB CData not yet supported in Painter's mode
> In graphics\private\render at 142
In print at 267
When I look at the eps file which is generated it contains the axes, but the surface is not drawn. If I use the zbuffer or OpenGL renderer, I do not get the warning and the surface shows up in the output file but it appears pixelated in the eps file.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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')

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!