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!

Answers (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

Categories

Asked:

on 29 Jan 2018

Commented:

on 12 Apr 2021

Community Treasure Hunt

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

Start Hunting!