How to reset the label range for a heatmap?

Hi all,
I am new to Matlab, could anyone help me on how to reset the label range of a heat map?
Following is my code and my result fig
T=readtable('water_density_map_cumulative_10172022/7500.dx.csv');
A = table2array(T);
A_interp = interp2(A,7);
colormap turbo
!imagesc(A_interp);
colorbar()
I2disp = A_interp;
I2disp(I2disp(:)<0.009) = nan;
pcolor(I2disp([1:end,end],[1:end,end])),shading flat,axis ij
The heatmap form is 4000*4000 and the fig label is just 0-4000 for both x and y, however I want it range from, 0-30, is there any way I can do this?
Thanks for any help!

 Accepted Answer

Sure. Use the alternate form for pcolor with the requested X, Y coordinates...
C=I2disp([1:end,end],[1:end,end]; % a temporary for convenience
[nR,nC]=size(C);
X=linspace(0,30,nC);
Y=linspace(0,30,nR);
pcolor(X,Y,C)

6 Comments

Thanks a lot for your quick reply!
The X,Y label seems to be ok now but the plot is wrong this time, it shows a totally black fig but not the heatmap I want. Could you give me some more instructions on this?
Also, here is the txt file I use as the data for plotting, please use it as you want if its helpful!
Show your full code -- all I did was take the argument you had for pcolor and make it a temporary from which to compute the size of the image from which to compute the ranges desired; that should make no difference at all in the displayed image being any different than yours. Hence, have to believe you made mistake somewhere, but we can't see what you did.
I think I figure it out! I did make some mistakes, and I just fixed them. Thanks a lot for the help!!
Glad to...moral is we can't fix what we can't see... :)
If the Answer provided the solution to the Q?, please Accept it if for no other reason to let others know it isn't still pending...
I just accepted it as the answer. Thanks for the help

Sign in to comment.

More Answers (0)

Categories

Products

Asked:

on 9 Jan 2023

Commented:

on 9 Jan 2023

Community Treasure Hunt

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

Start Hunting!