Custom colors for group of bars in bar plot
3 次查看(过去 30 天)
显示 更早的评论
I want to have custom colors for a group of bars in Matlab bar plot.
Like the one showed in the picture, but with different colors. I tried to use the following code but it shows stacked bars instead of the groups.
xdata = [1 2 3];
ydata = [10 20 30; 40 50 60; 5 6 7];
clr = [0 0.8 0;
0.3 0.8 0.8;
0 0 1];
for i = 1:length(xdata)
p = bar(xdata, ydata(i,:));
hold on
set(p,'FaceColor', clr(i,:));
end
Any help is appreciated. Thanks.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!