Unforunately the pie() function does not allow you to directly specify the face color of each wedge as inputs. Here are two ways to change the wedge colors after producing the pie plot.
Produce a demo pie chart & define colors
ax = gca();
pieData = [.3 .4 .3];
h = pie(ax, pieData);
newColors = [...
1, 0.41016, 0.70313;
0, 1, 0.49609;
0.59766, 0.19531, 0.79688];
Option 1 : change the axes colormap
You can use on of Matlab's many pre-defined colormaps or you can create your own has we've done above. This works with pie() and pie3() objects.
ax.Colormap = newColors;
ax.Colormap = spring(numel(h)/2);
Option 2: Change the FaceColor of the wedges
For pie() objects
patchHand = findobj(h, 'Type', 'Patch');
set(patchHand, {'FaceColor'}, mat2cell(newColors, ones(size(newColors,1),1), 3))
patchHand(2).FaceColor = 'r';
For pie3() objects
surfaceHand = findobj(h, 'Type', 'Surface');
patchHand = findobj(h, 'Type', 'Patch');
set(surfaceHand, {'FaceColor'}, mat2cell(newColors, ones(size(newColors,1),1), 3));
set(patchHand, {'FaceColor'}, mat2cell(repelem(newColors,2,1), ones(size(newColors,1)*2,1), 3));
Best Answer