主要特点:
•不需要参数传递。直接从绘图界面中提取所有值。
•鼠标点击或移动时直接产生反应。
•显示最接近鼠标指针的数据点,无距离限制。
•在曲线上与鼠标指针保持一定距离。
•为每条曲线显示一个单独的数据提示标题。
•将曲线的颜色复制为数据提示的方框颜色。
•也可以在GUIs中工作。
Features:
• No arguments to pass over. Retrieves all values out of the plot.
• Reaction on mouse click or mouse move.
• Displays the data point closest to the mouse pointer with no distance limit.
• Sticks on a curve by a certain distance to the mouse pointer.
• Displays for each curve an individual data tip title.
• Replicates the color of the curve as box color of data tip.
• Works also in GUIs.
局限性:
•二维绘图
•一个x轴,不反转,线性或对数。
•一个或两个y轴,不反转,线性或对数。
Limitations:
• 2D plot
• One x-axis, not reversed, linear or log.
• One or two y-axes, not reversed, linear or log.
Method:
• Get the mouse pointer location
• Retrieve all data out of the plot
• Translation of all data point to centimeters
• Translation of mouse pointer location to cm
• Set origin at mouse pointer location
• Translation to polar coordinates
• Determine closest point
• Translation of this point to normalized coordinates
• Display data tip
Manual:
Copy the principal of the examples for regular figure or GUI.
Note: Data tip title is stored in the plot UserData.
使用示例:
Short example:
hFig = figure;
plot(1:.1:2,2:.1:3,‘UserData’,‘My data tip title’);
%Track by mouse click:
set(hFig,‘windowbuttondownfcn’,@MouseTracking);
%Track by mouse move:
% set(h,‘windowbuttonmotionfcn’,@MouseTracking);
*) Remark to sticking:
The default value (delta) for sticking on a curve is 2 mm.
Example:
We work with polar coordinates. Only distances are relevant.
The origin is at the mouse pointer location.
With
dc: distance current curve point to mouse
dn: distance of next curve point to mouse
this holds:
dn < dc-delta, dn must be closer to the mouse pointer by delta.
Let us assume the two data points are 1 cm apart: dn-dc=1 cm
Then the next curve point dn must be closer than 0.4 cm to the mouse pointer in order to switch over to the next curve.
更多精彩文章请关注公众号: