linking brushing points in subplots

조회 수: 10 (최근 30일)
Jahandar Jahanipour
Jahandar Jahanipour 2016년 10월 13일
답변: Jahandar Jahanipour 2016년 10월 13일
Assuming we have two different 2D vectors A and B with same number of samples. In each subplot we scatter each matrix. I want to link the data between these two subplots so that if I brushed one point (e.g. 5th element in the matrix A. i.e. A(5,:)) it brushes the same point on the other subplot (5th element in the matrix B. i.e. B(5,:).
Is there any easy way to do that ?
I have already tried linkdata and linkprop functions but it didn't work out.
Thanks,

답변 (1개)

Jahandar Jahanipour
Jahandar Jahanipour 2016년 10월 13일
I found the answer and I thought that it might be useful for someone else. The idea is simple. Instead of having two Matrices A and B, write all the information in one matrix. so if you have
A = randn (10,2);
B = randn (10,2);
create a new matrix C and put all the points in that matrix:
C(:,1) = 1: size(A,1);
C(:,2:3) = A;
C(:,4:5) = B;
and simply scatter them separately:
subplot (1,2,1);
scatter (C(:,2), C(:,3));
subplot (1,2,2);
scatter (C(:,4), C(:,5));
linkdata on;
brush on;
There is a slight problem that if you do this, the linkdata pop up window will ask you to connect the XDataSources and YDataSources. You can link them directly on the pop-up window by changing all the A and B vectors to C vectors on the suggested list or you can simply clear A and B after you created the matrix C.
Hope it helps :)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by