You can use the Color Data (CData) property for bar graph released in R2017b.
You can change the color for a particular bar by setting the FaceColor property to 'flat'. Then, change the corresponding row in the CData matrix to the new RGB triplet. Here is the link for the CData property in bar graph:
For example,
a = [1,3,6;2,5,6;8,2,1];
H=bar(a, 'stacked');
colorSet = [];
for i = 1:3
myColors = round(rand(3,3),1);
colorSet = [colorSet myColors];
H(i).FaceColor = 'flat';
H(i).CData = myColors;
end
This will display the stacked bar plot with different colors.
Best Answer
To explain the issue, I am using the example found here:
https://www.mathworks.com/help/matlab/ref/bar3.html#bt1bonh
The code to create the bar charts is:
After creating the plot you can make the plots transparent by modifying the 'FaceAlpha' property of each group of bar charts in the bar3d object:
In addition, here is further information on changing the colors of the each group of bars individually:
https://www.mathworks.com/matlabcentral/answers/5424-how-to-colorize-individual-bar-in-bar3
Alternatively, you can set a different palette using the "colormap" command:
https://www.mathworks.com/help/matlab/ref/colormap.html