MATLAB Answers

How to link cameras for two subplots in a single figure

27 views (last 30 days)
Shailen
Shailen on 21 Jul 2011
Commented: Alberto Mora on 24 May 2018
Hi all,
I draw two subplots in a figure using patch. Now I was wondering if there is a way to link the two cameras together i.e. if I rotate the camera in one of the plots, the other plot in the figure does the same rotation simultaneously (similar to link camera option found in paraview).
Thanks in advance ! Cheers !

  0 Comments

Sign in to comment.

Answers (1)

Jan
Jan on 23 Jul 2011
ax1 = subplot(1, 2, 1);
pcolor(rand(10));
ax2 = subplot(1, 2, 2);
pcolor(rand(10));
Link = linkprop([ax1, ax2], ...
{'CameraUpVector', 'CameraPosition', 'CameraTarget'}
setappdata(gcf, 'StoreTheLink', Link);
Now rotating one object, acts on the other simultaneously. Perhaps you want to link the 'CameraViewAngle' also.

  1 Comment

Alberto Mora
Alberto Mora on 24 May 2018
I think that you forgot one bracket at the end of "Link =":
Link = linkprop([ax1, ax2], ...
{'CameraUpVector', 'CameraPosition', 'CameraTarget'});
setappdata(gcf, 'StoreTheLink', Link);
Best

Sign in to comment.

Sign in to answer this question.


Translated by