[英]change color to bar plot Matlab
我有矩陣A,我做了一個小圖
A = rand(15,9);
h = bar(A);
現在我想根據下面定義的色圖“ colorset”為每組條形(A的每一行)着色
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]
我嘗試做類似的事情
set(get(h,'children'),'cdata', A );
colormap(colorset);
但沒有運氣
我認為這應該有所幫助:
for hi = 1:numel(h)
set(h(hi), 'FaceColor', colorset(hi,:))
end
之前(原色):
之后(新顏色):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.