Custom Data Cursor

版本 1.0.0.0 (2.2 KB) 作者: Dave Van Tol
This function allows a user to label each point in a data series with custom labels.
2.5K 次下载
更新时间 2008/5/22

查看许可证

customDataCursor allows a user to label each point in a data series with custom labels. When the data cursor mode is enabled (DATACURSORMODE ON), clicking on a data point will display the custom label, then the x and y values of the data point. If more than one data point of the data series is in the same location, the data cursor will display all of the labels first, then the x and y locations.

Usage: customDataCursor(H,DATALABELS) applies the custom labels found in cell array DATALABELS to the line with handle H. DATALABELS must be a cell array with the same length as 'XDATA' and 'YDATA' in the line; in other words, there must be a label for each data point in the line.

dcmH = customDataCursor(H,DATALABELS) returns the handle to the data cursor in dcmH.

Note: CUSTOMDATACURSOR uses the 'UserData' property of a line to store and retrieve the labels. If that property is used by another portion of a user's program, this function may be broken, or this function may break the user's program.

Example:
% generate some data and chart it
N = 20;
x = rand(N,1);
y = rand(N,1);
h = plot(x,y,'ko');
% make up some labels and apply them to the chart
labels = cell(N,1);
for ii = 1:N
labels{ii} = ii;
end
customDataCursor(h,labels)

引用格式

Dave Van Tol (2025). Custom Data Cursor (https://www.mathworks.com/matlabcentral/fileexchange/18773-custom-data-cursor), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Data Exploration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Modified code to fix bug reported by Ahmed Andalusi. Although I could not recreate the error message reported, I think I understand the offending line of code and have changed it to use a cell array rather than a string array. Thanks, Ahmed.