How to plot this colormap correctly?

I am trying to plot a heat map of temperature along depth and time. However the plot does not match the provided data. For instance at z = -8612 m I have T = 80.57°C, but it would be something near 165°C.
I attached my .mat files, the depth, time and temperature data. My code to plot is:
% Plotting
figure;
imagesc(time, depth, temp);
colormap('jet');
colorbar;
xlabel('Time');
ylabel('Depth');
title('Temperature Heat Map');
set(gca, 'YDir', 'normal');
Could someone please give me any idea of what is happening here?
Thanks!

 Accepted Answer

Voss
Voss on 11 Mar 2024
Edited: Voss on 11 Mar 2024
The difference between adjacent elements of depths is not constant. (Same for time.)
load depth
load temp
load time
% difference between adjacent elements of depths:
disp(diff(depths.'))
Columns 1 through 33 -211 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 34 through 66 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 67 through 99 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 100 through 132 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 133 through 165 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 -200 -210 -220 -230 -240 Columns 166 through 170 -250 -260 -270 -280 -292
An image uses equally-sized pixels, so it's not an appropriate choice to represent data like this where the x- and y- spacing is not constant.
Better is to use a surface:
surface(time, depths, temperature, 'EdgeColor', 'none')
xlim(time([1 end]))
ylim(depths([end 1]))
colormap('jet');
colorbar;
xlabel('Time');
ylabel('Depth');
title('Temperature Heat Map');
set(gca, 'YDir', 'normal');

2 Comments

Perfect!! Many thanks for the solution!!
You're welcome!

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Asked:

on 11 Mar 2024

Commented:

on 11 Mar 2024

Community Treasure Hunt

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

Start Hunting!