Gradient coloring in histogram/Histogram color
12 ビュー (過去 30 日間)
古いコメントを表示
Hi,
Lets say I have a two matrix Output, Outpu1.
I am creating a histogram from the entries of matrix Output as follows
histogram(Output,'Normalization', 'probability','FaceColor','black');
I am wondering, Is there a possibility to apply gradient coloring to histogram based on the values in the matrix Output1
2 件のコメント
Adam Danz
2022 年 6 月 30 日
Both variables are 3614x1 vectors. The histogram produces n bins from the Output vector. How should the Output1 vector be used to apply gradient coloring to the histogram bars?
回答 (1 件)
Tushar
2023 年 9 月 22 日
Hi,
I understand that you are looking to apply gradient coloring to a histogram based on the values in a matrix 'Output1'.
You need to divide the values in 'Output1' into categories of unique values. Here is how you can do it:
a = categorical(Output1);
B = categories(a); %B will contain unique values from Output1
I would suggest using bar instead of histogram. We can control individual bar colors using the 'CData' property of the bar object.
You can refer to the following MATLAB Answers which are based on the similar doubt:
- https://www.mathworks.com/matlabcentral/answers/113243-changing-the-histogram-color
- https://www.mathworks.com/matlabcentral/answers/1681664-colours-of-a-histogram
For more information, refer to 'Control Individual Bar Colors' section in the below documentation:
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!