MATLAB: Zooming separately on both data sets while using plotyy

plotyy zoom plot

Is there anyway that I can selectively zoom on the two data sets when I am using plotyy?
In other words I want to re-scale and position the the data separately after plotting and can't seem to make this happen as of now. I came across the following but, I wasn't sure how I could convert it into a function for automatic plotting using plotyy:

Best Answer

The sense of PLOTYY is the joining of the data-sets. When you want to handle them separately, do not use PLOTYY, but create the two axes manually:
AxesH(1) = axes('NextPlot', 'add', ...
'XAxisLocation', 'bottom', ...
'YAxisLocation', 'left');
AxesH(2) = axes('NextPlot', 'add', ...
'XAxisLocation', 'top', ...
'YAxisLocation', 'right', ...
'Color', 'none');
plot(1:10, rand(1:10), 'Color', [1,0,0], 'Parent', AxesH(1), ...
'ButtonDownFcn', {@LineSelect, AxesH});
plot(1:10, rand(1:10), 'Color', [0,0,1], 'Parent', AxesH(2), ...
'ButtonDownFcn', {@LineSelect, AxesH});
function LineSelect(ObjectH, EventData, AxesH)
SelectedAxes = get(ObjectH, 'Parent');
Fig = ancestor(SelectedAxesH, 'Figure');
set(Fig, 'CurrentObject', SelectedAxes);
% Now an idea is missing
Finally the code can activate an axes, but I'm not sure if the zooming is restricted to this axes. So this is only a rough idea yet.