Playing with ActionPostCallback
and ActionPreCallback
is certainly a solution, but probably not the most efficient one. One may use linkprop
function to synchronize the camera position property.
linkprop([h(1) h(2)], 'CameraPosition'); %h is the axes handle
linkprop
can synchronize any of graphical properties of two or more axes
(2D or 3D). It can be seen as an extension of the linkaxes
function that works for 2D plots and synchronizes the axes
limits only. Here, we can use linkprop
to synchronize the camera position property, CameraPosition
, the one that is modify when one rotate an axes
.
Here is some code
% DATA
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z1 = sin(R)./R;
Z2 = sin(R);
% FIGURE
figure;
hax(1) = subplot(1,2,1); %give the first axes a handle
surf(Z1);
hax(2) = subplot(1,2,2); %give the second axes a handle
surf(Z2)
% synchronize the camera position
linkprop(hax, 'CameraPosition');
You can have a list of the graphical properties with
graph_props = fieldnames(get(gca));