Extract X,Y data from scatter plot

조회 수: 50 (최근 30일)
Pichawut Manopkawee
Pichawut Manopkawee 2020년 9월 26일
댓글: Pichawut Manopkawee 2020년 9월 27일
Hi All,
Could you giving a code or advice how to extract X,Y data from a scattered plot?
I have tried several ways following previous suggestions on website, none of that works for me.
I've attached the figure as what I want to extract those values out.
I strongly hope that one of you might help me solve this issue.
Thanks in advance,
Pete
  댓글 수: 4
Cris LaPierre
Cris LaPierre 2020년 9월 26일
If you haved the data used to create the plot, there are better ways of doing this. You can figure out what X is from the plotting code. What is you plot command?
Pichawut Manopkawee
Pichawut Manopkawee 2020년 9월 26일
This is a plot command
semilogx(saproduct,laplacian,'k.','markersize',8);
saproduct and laplacian are two matrix containing values of 756x519 single

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 9월 26일
Assuming you have a *.fig file and not a .png, first open the fig file in MATLAB then run the following code.
s=findobj(gca,'Type','Scatter');
X = s.XData;
Y = s.YData;
  댓글 수: 6
Cris LaPierre
Cris LaPierre 2020년 9월 26일
편집: Cris LaPierre 2020년 9월 26일
Now we're getting somewhere! When passed matrices, MATLAB will plot each column as its own series. That means your semilogx plot is made up of 519 data series with 756 data pairs in each one. Since you are setting your marker color, you probably noticed that (each series is assigned a different color). To extract the data from the figure, you would have to loop through each line object, combining the data as you go.
Luckily, since you have the data and are creating the plot, we don't have to do that. We can use linear indexing instead to create the exact same semilogx plot, but with all the data in a single series. This makes it easier to figure out the [X,Y] pairing. Linear indexing turns both matrices into column vectors by stacking the columns on top of each other (column 2 is directly under column 1, etc).
X = saproduct(:);
Y = laplacian(:);
semilogx(X,Y,'k.','markersize',8)
X and Y are vectors with size 392364 x 1.
Pichawut Manopkawee
Pichawut Manopkawee 2020년 9월 27일
Thank you so much Cris LaPierre

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by