После небольшого рутинга вокруг существующего кода всплывающей подсказки вот что я придумал. Ключ получал дескрипторы для структур подсказок данных через функции datacursormode () и getcursorInfo () .
Каждая построенная линия представляет собой подмножество векторов данных, которые взяты из оригинального набора данных. Если у вас есть пользовательская подсказка данных, у вас есть доступ к индексу данных, используемых для графика. Это не то же самое, что индекс в исходном наборе данных. Таким образом, некоторое предварительно рассчитанное отображение используется для получения исходного индекса из индекса всплывающей подсказки. Это отображение здесь не показано, но оно было включено в свойство UserData линейного графика. (Это требует некоторого кодирования со стороны пользователя.)
function getDataTipsData(src,event)
% Several plots are on a figure.
% The button that was pushed is a child of the figure (by design).
% src is the handle of the button.
% src.Parent is the figure handle
p = src.Parent;
% Obtain a structure that contains the datatip information using these steps
dcm = datacursormode(p);
info_dcm = getCursorInfo(dcm);
% The button may have user data attached to it as part of its instantiation
% and configuration
plotTitle = src.UserData.plotTitle;
% Allocate an array
some_user_data_from_each_datatip = zeros(1,numel(info_dcm));
% Iterate through the datatips and extract the data from each one
if ~isempty(info_dcm)
for i = 1:numel(info_dcm)
% Get the index into the array that the datatip is referencing.
% Sinde there may be moultiple plots on the figure, this index
% is specific to the x,y (and z) data of the line this datatip
% is referencing.
idx_subset = info_dcm(i).DataIndex;
% Target is the line object that ther datatip is referencing. It
% has pre-established user data, that was added to the plot when
% it was originally plotted.
tgt_data = info_dcm(i).Target.UserData;
% ioi is a vector of indices of interest, which maps the index within the
% data used for this line into the index of the original dataset.
idx_original = tgt_data.ioi(idx_subset);
some_user_data_from_each_datatip(i) = tgt_data.some_field(idx_original);
end
end