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);
本文介绍了一个使用MATLAB实现的交互式绘图功能示例。通过定义回调函数,用户可以选择不同的图线并将其以相同颜色显示在另一组坐标轴上。此功能增强了数据可视化的效果,并允许用户更直观地对比不同数据集。
123

被折叠的 条评论
为什么被折叠?



