How to set x-ticks and y-ticks for the Raman image?
1 view (last 30 days)
Show older comments
Anshul Choubey
on 8 Feb 2022
Commented: Star Strider
on 8 Feb 2022
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])
0 Comments
Accepted Answer
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')
[Uy,ia] = unique(T1.('Y-coordinate'));
Udia = unique(diff(ia))
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.
.
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!