How to remove connecting lines in the line plot for large dataset?

I have a Raman spectroscopy data for an area of 400x400 micrometer. The data is in the form of table. The table consits of coordiantes X,Y, Wavenumber and Normalized Intensity . The table is (319,725 by 4 )matrix. X&Y represents the coordinates. Normalized Intensity and Wavenumber corresponds to one coordinate. For each coordiante, there are 1015 values of Wavenumber and Normalized Intensity.
I wanted to plot a line graph between normalized Raman intensity and wavenumber and I get a connecting line in the graph.
Is it possible to remove the line in the graph?
clear all
Raman_data=readtable("Raman_Data_New.xlsx")
Raman_data_new=Raman_data(:,{'Wavenumber','Intensity'})
W=Raman_data_new(:,"Wavenumber");
I=Raman_data_new(:,"Intensity");
plot(W{1:3029,"Wavenumber"},I{1:3029,"Intensity"})
grid on
title('Raman Intensity vs Wavenumber')
xlabel('Wavenumber /cm')
ylabel('Normalized Raman Intensity')
histogram(I{:,"Intensity"})
histogram2(W{:,"Wavenumber"},I{:,"Intensity"})

2 件のコメント

Benjamin Thompson
Benjamin Thompson 2022 年 1 月 27 日
Where is Raman_data defined? Can you post something that defines this variable?
Anshul Choubey
Anshul Choubey 2022 年 1 月 27 日
I have included the excel file in the attachment. The data looks like this.

サインインしてコメントする。

 採用された回答

Ankit
Ankit 2022 年 1 月 27 日
編集済み: Ankit 2022 年 1 月 27 日
You can use unique to resolve this problem.
unique(A) for the array A returns the same values as in A but with no repetitions.
x = [600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 600 650 700 750 800];
y = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 2 3];
[~,idx] = unique(x);
x_new = x(idx);
y_new = y(idx);
plot(x,y,'r');hold on;plot(x_new,y_new,'-.b');

6 件のコメント

Anshul Choubey
Anshul Choubey 2022 年 1 月 27 日
Thanks for the answer. But this doesnt work. I would like to draw the graph for each coordiante. For example a coordiate (-236,-130) has 1 Raman spectrum reading (1015 values of Intensity vs Wavenumber). There are 315 coordiantes. If my data set was small, I would have split the data into different columns and plotted the graph easily. But my dataset has 319,725 rows. (315X1015)
Ankit
Ankit 2022 年 1 月 27 日
Yes after seeing your data this solution will not work.. as your x data is not monotonically increasing you are getting this behavior. What is your requirement? Is it fine to plot the results for different values of x
Ankit
Ankit 2022 年 1 月 27 日
tSplitPoint = min(Raman_data(:,3)); idxChange = find(Raman_data(:,3)<=tSplitPoint);
x = Raman_data(1:idxChange(1,1),3);
y = Raman_data(1:idxChange(1,1),4);
x1 = Raman_data(idxChange(1,1)+1:idxChange(2,1),3);
y1 = Raman_data(idxChange(1,1)+1:idxChange(2,1),4);
x2 = Raman_data(idxChange(2,1)+1:end,3);
y2 = Raman_data(idxChange(2,1)+1:end,4);
plot(x,y,'r',x1,y1,'r',x2,y2,'r');
Anshul Choubey
Anshul Choubey 2022 年 1 月 27 日
Thank you very much for the help. This is what I was looking for and it worked. I would like to ask further, Can I use ''for loop'' for plotting all the coordiantes? I have used the following code for spliting the table. But I am confused on how to apply it for the plot function.
for k=1:3
x=Raman_new(1:idxChange(k,1),3)
y=Raman_new(1:idxChange(k,1),4)
end
Ankit
Ankit 2022 年 1 月 28 日
tSplitPoint = min(Raman_data(:,3));
idxChange = find(Raman_data(:,3)<=tSplitPoint);
idxnew = [idxChange;length(Raman_data(:,3))];
xstart = 1;
for i = 1:length(idxnew)
plot(Raman_data(xstart:idxnew(i,1),3),Raman_data(xstart:idxnew(i,1),4),'r');hold on
xstart = idxnew(i,1)+1;
end
Anshul Choubey
Anshul Choubey 2022 年 1 月 28 日
Thank you for the answer and the help. It saved a lot of time for my project.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by