No 'CData' property on bar graph
10 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to make a bar graph and adjust the colors of individual bars. The most helpful online answers on how to do this involve using the 'CData' property of the bar object. However, in my particular bar graph, generated by the following code, there is no 'CData' property, and I'm confused as to why. Any help would be greatly appreciated!
eyesPlot = bar(1:4,eyesArray(:,2));
2 件のコメント
回答 (2 件)
Tom Holmes
2017 年 11 月 9 日
This worked for me with 2017a release:
figure
BarMatrix = [your_matrix_here];
b = bar(BarMatrix,1,'LineStyle','none');
CData = lines(4);
for k = 1:size(BarMatrix,2)
b(k).FaceColor = CData(k,:);
end
0 件のコメント
Roger Breton
2024 年 1 月 18 日
Does not work for me?
I use:
data = [1 2 3 4];
figure
BarMatrix = [1 2 3 4];
b = bar(BarMatrix,1,'LineStyle','none');
CData = lines(4);
for k = 1:size(BarMatrix,2)
b(k).FaceColor = CData(k,:);
end
And all I get are four solid bars of blue?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!