Scatter plot with two data sets of uneven values

조회 수: 15 (최근 30일)
Vince Clementi
Vince Clementi 2020년 1월 10일
댓글: Adam Danz 2020년 1월 10일
Hi All,
Is it possible to create a scatter plot using two datasets of uneven values. For example, D1 and D1 both have x values that span 0 120 and y values of different parameters (D1 = oxygen, D2 = chlorine). However, D1 consists of 80 data points, and D2 consists of ~20. Moreover, the x values for D1 and D2 do not overlap.
If not, is there a recommended solution to make this easier? The only thing I can think of is to resample the data to a common axis, but that introduces data that are not real.
Thanks!
  댓글 수: 9
Vince Clementi
Vince Clementi 2020년 1월 10일
I expect a fairly linear relationship between the variables. Option 2 sounds reasonable, but it would be best to mitigate any spruious data.
Adam Danz
Adam Danz 2020년 1월 10일
"Option 2 sounds reasonable"
It sounds like this decision hasn't been though out. The results will not be meaningful unless the pairing is meaningful. There are lots of ways to pair the two datasets and each of them will produce a very different result with a different interpretation.

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

채택된 답변

Adam Danz
Adam Danz 2020년 1월 10일
편집: Adam Danz 2020년 1월 10일
Here's a demo you can follow.
It produces 2 datasets per your description; then it pairs the y values from dataset1 to dataset 2 according to proximity of the x values.
Then in plots the results. The data are random so don't expect linearity.
% Produce 2 datasets, one longer than the other; x values range from 0:110
dataset1 = [rand(100,1)*110, rand(100,1)];
dataset2 = [rand(50,1)*110, rand(50,1)*10];
% Find the rows of dataset1 that is closest to the
% x values in dataset 2
D = pdist2(dataset1,dataset2); % distance between each (x,y)
% D = pdist2(dataset1(:,1),dataset2(:,1)); % distance between each (x)
[~, minRow] = min(D);
% Plot results
plot(dataset1(minRow,2), dataset2(:,2),'o')
  댓글 수: 4
Vince Clementi
Vince Clementi 2020년 1월 10일
Great modification that strengthens the method. Thank you.
Adam Danz
Adam Danz 2020년 1월 10일
Glad it worked out!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by