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
Akira Agata 2018년 2월 5일

1 개 추천

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

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2018년 1월 29일

댓글:

2021년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by