How to set x-ticks and y-ticks for the Raman image?

1 view (last 30 days)
I would like to set x-ticks and y-ticks labels for my Raman Intensity Ratio image. My data consists of Raman intensity ratio for each coordinate of X axis and Y- axis.
The Raman intensity ratio data was collected in step size of 20µm. The X-axis starts from -195 µm till 204µm. The Y-axis -122µm to 137µm. I have attached an image of the result. I am not able to see the xticks and y-ticks on the image.
Also would it be possible to get the coordinate value from the image? I am intrested in the coordinate which are red in color. This would help me to get a Raman Intensity vs Wavenumber for a particular coordiante.
clear all
clear vars
%Loading data
Raman_Ratio=readtable("Raman Intensity Ratio.xlsx");
%Define variables
X_start=Raman_Ratio{1,"X_coordinate"};
X_end=Raman_Ratio{end,"X_coordinate"};
Y_start=Raman_Ratio{:,"Y_coordinate"};
Y_end=Raman_Ratio{end,'Y_coordinate'};
X_cord=Raman_Ratio{:,"X_coordinate"};
Y_cord=Raman_Ratio{:,"Y_coordinate"};
RI=Raman_Ratio{:,"IntensityRatio"};
% Grid of coordinates for above data
xi=X_start:20:X_end;
yi=Y_start:20:Y_end;
[X,Y]=meshgrid(xi,yi);
% For finer grid of points
m_2=X_start:1:X_end;
n_2=Y_start:1:Y_end;
[X2,Y2]=meshgrid(m_2,n_2);
%Interpolating the values of Raman Ratio into the grid
Z=griddata(X_cord,Y_cord,RI,X2,Y2);
%Showing the data as image
imshow(Z)
colormap("jet")
%adding xticks and xlabels
xticks([X_start 20 X_end])
xticklabels('auto')
%Defining a colorbar
c1=colorbar;
c1.Label.String='Raman Intensity Ratio';
caxis([0.5 0.8])

Accepted Answer

Star Strider
Star Strider on 8 Feb 2022
Try this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/887625/Raman%20Intensity%20Ratio.xlsx', 'VariableNamingRule','preserve')
T1 = 294×3 table
X-coordinate Y-coordinate Intensity Ratio ____________ ____________ _______________ -195.29 -122.38 0.67591 -175.29 -122.38 0.65792 -155.29 -122.38 0.6517 -135.29 -122.38 0.67788 -115.29 -122.38 0.65057 -95.289 -122.38 0.6676 -75.289 -122.38 0.6626 -55.289 -122.38 0.61923 -35.289 -122.38 0.66892 -15.289 -122.38 0.63612 4.7108 -122.38 0.65157 24.711 -122.38 0.62615 44.711 -122.38 0.63971 64.711 -122.38 0.65806 84.711 -122.38 0.65193 104.71 -122.38 0.63174
[Uy,ia] = unique(T1.('Y-coordinate'));
Udia = unique(diff(ia))
Udia = 21
Xm = reshape(T1.('X-coordinate'), Udia, []);
Ym = reshape(T1.('Y-coordinate'), Udia, []);
Zm = reshape(T1.('Intensity Ratio'), Udia, []);
figure
surfc(Xm, Ym, Zm)
grid on
shading('interp')
colormap(turbo)
c1=colorbar;
c1.Label.String='Raman Intensity Ratio';
xlabel('X')
ylabel('Y')
zlabel('Intensity Ratio')
view(0,90)
axis('equal') % Optional
The data are gridded, so it is necessary to reshpae them to matrices. That is straightforward once the details of the grid are known (privided by ‘Udia’ here).
Using imshow flips the y-axis, because that is the coordinate convention for images.
The surf plot shows the correct orientation and coordinates.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!