필터 지우기
필터 지우기

Gradient coloring in histogram/Histogram color

조회 수: 15 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2022년 6월 30일
답변: Tushar 2023년 9월 22일
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
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?
Turbulence Analysis
Turbulence Analysis 2022년 6월 30일
For instance, here first three entries in output pertains to 8.59 of output 1, likewise entries 5 to 18 in output pertains to 10.59 of output1
So essentially the values in output that pertains to 8.59 should be in one color and the one that belongs to 10.59 will be in another color..

댓글을 달려면 로그인하십시오.

답변 (1개)

Tushar
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:
For more information, refer to 'Control Individual Bar Colors' section in the below documentation:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by