function tmp(src,event,hAx)
% This callback displays the selected line on a different set of axes
x = event.Peer.XData; % Get X data of interest
y = event.Peer.YData; % Get Y data of interest
plot(hAx,x,y,'Color',event.Peer.Color) % Plot data with the same color
title(hAx,event.Peer.DisplayName) % Set the title to the line name
end
subplot(2,1,1)
plot(x,y1,x,y2,x,y3,x,y4)
hLeg = legend('Line 1','Line 2','Line 3','Line 4');
hAx = subplot(2,1,2);
hLeg.ItemHitFcn = @(src,event) tmp(src,event,hAx);