Reputation: 5569
I have the matrix A and I make a barplot
A = rand(15,9);
h = bar(A);
now I would like to color each group of bars (each row of A) according to the colormap "colorset" defined below
colorset = [0 0 1;...
1 0 0;...
0 1 0;...
0 0 0.172413793103448;...
1 0.103448275862069 0.724137931034483;...
1 0.827586206896552 0;...
0 0.344827586206897 0;...
0.517241379310345 0.517241379310345 1;...
0.620689655172414 0.310344827586207 0.275862068965517]
I try to do something like
set(get(h,'children'),'cdata', A );
colormap(colorset);
but no luck
Upvotes: 1
Views: 488
Reputation: 238557
I think this should help:
for hi = 1:numel(h)
set(h(hi), 'FaceColor', colorset(hi,:))
end
Before (orginal colors):
After (new colors):
Upvotes: 0