How do I make a 1D continuous heatmap?
이전 댓글 표시

I am trying to make 1D-continuous heatmap for my data, something like the image on the top. My data range is between 0-1 and has random values between the limits. However, when I try to plot it, it gives me intensities of the individual values as separate boxes. I do not what this. I want my data to be automatically scaled to plot values between 0-1, with recurring numbers (such as 0.9) showing a dark color and less frequent numbers with a lighter tone.
In summary, what I am trying to do it have my data be represented in form of an intensity gradient.
I am currently using the following code:
n = [data]
heatmap (n,'colorscaling','scaled','colorlimits',[0 1])
caxis([0,1])

Any help will be appreciated!
답변 (1개)
Akira Agata
2018년 2월 5일
How about using imagesc function? The following is an example.
data = rand(1,100); % sample data
map = interp1([0;1],[1 1 1;0 0.45 0.74],0:0.01:1); % color map
imagesc(data)
colormap(map)
colorbar

댓글 수: 1
Omer Mujahid
2021년 4월 12일
Imagesc does not improve much on the heatmap.
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!