MATLAB: How to Create a seperate colormap for each pi-chart in a subplot

colormappiepie chartsubplot

if true
% code
labels={'A','B','C','D','E','F'};
data=[22,19,11,16,11,21]';
wedge=[0,0,0,0,0,1]';
figure
subplot(1,3,1);
pie(data,wedge,labels);
colormap([0,0,1;0,1,1;0,1,0;1,0,0;1,0,1;0,0,0]);
title('Raw Data')
subplot(1,3,2);
pie(data(1:end-1),labels(1:end-1));
% colormap([0,0,1;0,1,1;0,1,0;1,0,0;1,0,1]);
title('Data Excluding F');
subplot(1,3,3);
data2=[(data(1)+data(2)),data(3),(data(4)+data(5))]';
labels2={'A+B','C','D+E'};
pie(data2,labels2);
% colormap([0,0,1;0,1,1;0,1,0]);
title('Groups');
end
If only the the first colormap is run: </matlabcentral/answers/uploaded_files/133805/CM1.PNG> If the first line and second colormap is run, the second one applies the second colormap to the first subplots: </matlabcentral/answers/uploaded_files/133806/CM2.PNG> If the first line second and third colormap is run, the third one applies the second colormap to the first and second subplots: </matlabcentral/answers/uploaded_files/133807/CM3.PNG>
How can I specify an individual colormap for each subplot?

Best Answer

just insert the handle as the first argument of colormap
colormap(gca,cmap);
minimal working example
subplot(1,2,1);
peaks
colormap(gca,'hot')
subplot(1,2,2);
peaks
colormap(gca,'jet')