I did a 3D bar plot in Matlab. I want the same color for each group (for example s1=blue, s2=green and s3=red; see the graph below)
I used the following code:
Z = data;
Y = [1 300 600]; % The positions of bars along the y axis
h = bar3(Y,Z',0.05);
[nGroup, nBar] = size(Z);
nColors = size(get(gcf, 'colormap'), 1);
colorInd = randi(nColors, nBar, nGroup);
for i = 1:nGroup
c = get(h(i), 'CData');
color = repelem(repmat(colorInd(:, i), 1, 4), 6, 1);
set(h(i), 'CData', color);
end
set(gca, 'YTickLabel',
any suggestions?