Yeping
the range in imshow( , ,[range]) does not change the axis ticking.
For such purpose, to change the X axis ticks to [-2.5 2.3] and Y axis to [-2.8 2.3] you have to capture the axis handle, and access the right fields called XTickLabel and YTickLabel.
First.-
modify your code, where you imshow the heatMap adding the handle or pointer f3:
f3=figure(3);imshow(heatMap, []); axis on; colormap(hot(256)); colorbar;
now capture the handle to the axis of the figure 3:
have a look to the current X ticking:
Lx=ax3.XTickLabel
Lx =
'100'
'200'
'300'
'400'
'500'
'600'
'700'
You say you want [-2.3 2.5] range, let's have the X axis ticking with same amount as it is for [100 700], with numel(Lx)
Lx2=linspace(-2.3,2.5,numel(Lx))
Because cells have variable length, use this loop to have '-' and other length variations correctly converted to cell type:
Lx_cell={};
for k=1:1:numel(Lx)
L1=num2str(Lx2(k));
Lx_cell=[Lx_cell L1];
end
Lx_cell=Lx_cell';
Now directly apply the new tick labels
f3.CurrentAxes.XTickLabel=Lx_cell
f3 =
Figure (3) with properties:
Number: 3.00
Name: ''
Color: [0.94 0.94 0.94]
Position: [501.00 161.00 872.00 795.00]
Units: 'pixels'
the command window doesn't show, but now
f3.CurrentAxes.XTickLabel
ans =
'-2.3'
'-1.5'
'-0.7'
'0.1'
'0.9'
'1.7'
'2.5'
check your figure
And for the Y axis
Ly2=linspace(-2.8,2.3,7)
Ly_cell={};
for k=1:1:7
L2=num2str(Ly2(k));
Ly_cell=[Ly_cell ;L2];
end
f3.CurrentAxes.YTickLabel=Ly_cell
Yeping
If you find my answer useful would you please be so kind to mark it as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG
Best Answer