필터 지우기
필터 지우기

Synchronise different viewing angles onto same scatter plot

조회 수: 11 (최근 30일)
Lima Kilo
Lima Kilo 2016년 9월 2일
댓글: Lima Kilo 2016년 9월 5일
I'm trying to have a figure with two subplots (or preferably even two separate figures), showing the same 3d point cloud, but from different viewing angles. I would like to see the same point cloud from two different angles to get a better feeling for the points' locations in the 3d space, and I must be able to rotate the plots in sync. I managed to have 2 plots synchronised using linkprop, but I can't change the angle of one of the plots once they're synced.
Thanks for any help!
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 9월 2일
The rotate tool changes view() which in turn changes the axes CameraPosition and CameraViewAngle . Considering that you want different viewing angles, exactly what is it that you want to be synchronized between the two? CameraPosition, CameraViewAngle, CameraTarget, CameraUpVector ?
In terms of view, if the first plot is
view(a,b)
then what should be the view() for the second plot?
Lima Kilo
Lima Kilo 2016년 9월 5일
I want to have the view synchronised. If the first plot was
view(a,b)
then I would like the second one to be something like
view(a+20,b+20)
Sorry for my late reply, but I didn't see that only answers, not comments, would get email notifications.

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

채택된 답변

Walter Roberson
Walter Roberson 2016년 9월 5일
You will need to use addlistener for changes to the CameraPosition and CameraViewAngle properties . In the listener, you can call view() on the first axis to find the values that you would then add 20 to and call view() for the second axes.
linkprop and linkaxes are only for synchronizing exact values, and do not provide for computing one property based upon the other.
  댓글 수: 5
Walter Roberson
Walter Roberson 2016년 9월 5일
Okay, it appears that you can addlistener on 'View', at least in R2016a.
Lima Kilo
Lima Kilo 2016년 9월 5일
Awesome, that works. Thanks!
If someone else has the same problem, here is a minimum working example:
f1 = figure;
subplot(1,2,1)
sc1 = scatter3(1,1,1,'r+');
subplot(1,2,2)
sc2 = scatter3(1,1,1,'g+');
subplot(1,2,1)
lh1 = addlistener(gca, 'View','PostSet',@viewChangedCallback)
and the callback function:
function viewChangedCallback(src,evt)
subplot(1,2,1)
[az, el] = view(gca);
subplot(1,2,2)
view(gca, az+20, el+20);
subplot(1,2,1)
For robustness, gca should be replaced with fixed references.

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

추가 답변 (0개)

카테고리

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