Because this behavior doesn't seem to be present in a 'normal' plot
call, this looks like an internal bug with the creation of the axes objects by plotyy
. As one alternative, you can stack multiple axes on top of each other and therefore utilize the 'default' (for lack of a better word) zoom behavior. This approach also allows you to fully control the behavior of both axes independently and avoid the seemingly many foibles of plotyy
.
I've slightly adapted one of my previous answers as an example for this situation.
% Sample data
x = 1:10;
y1 = 1:2:20;
y2 = 1:0.5:5.5;
% Create axes & store handles
h.myfig = figure;
h.ax1 = axes('Parent', h.myfig, 'Box', 'off');
if ~verLessThan('MATLAB', '8.4')
% MATLAB R2014b and newer
h.ax2 = axes('Parent', h.myfig, 'Position', h.ax1.Position, 'Color', 'none', 'YAxisLocation', 'Right');
else
% MATLAB 2014a and older
ax1position = get(h.ax1, 'Position');
h.ax2 = axes('Parent', h.myfig, 'Position', ax1position, 'Color', 'none', 'YAxisLocation', 'Right');
end
% Preserve axes formatting
hold(h.ax1, 'on');
hold(h.ax2, 'on');
% Plot data
plot(h.ax1, x, y1, 'b');
plot(h.ax2, x, y2, 'g');
linkaxes([h.ax1, h.ax2], 'x');
And a sample image:

Note that I've only linked the x
, but you can link both x
and y
axes with the linkaxes
call.