MATLAB Answers


Data Tips -- Add Row Error

Asked by autumn
on 10 Jun 2019
Latest activity Commented on by Jan
on 11 Jun 2019
I'm plotting several things at once and would like to be able to add a data tip row in order to identify the different lines I have running across the plot. Here's my code (I replaced my variables with 'yes' and 'yeehaw'):
for k = 1:length(objects) % yes, yeehaw, and Name are all structs
index = objects(k);
p = plot3(yes(index).yeehaw(:,1),yes(index).yeehaw(:,2),...
str = yes(index).Name;
fh = str2func(str);
row = dataTipTextRow('yes or yeehaw',fh);
p.DataTipTemplate.DataTipRows(end+1) = row;
And then there are some modifiers for my plot and stuff before the loop closes. I keep getting the following error:
Error using Value must be a string scalar or a character vector with the name of a data property, such as 'XData', or it must be a vector or a function handle.
What can I do?


Sign in to comment.

1 Answer

Answer by Jan
on 10 Jun 2019

There is no way to provide the value of the data tips as function handle. I cannot guess, what the purpose of using str2func(str) is.


I've read both, yes, and nothing seems to work. I've also tried
row = dataTipTextRow('oops',yes.yeehaw);
p.DataTipTemplate.DataTipRows(end+1) = row;
And that doesn't seem to work either.
on 11 Jun 2019
"Nothing seems to work" is not a useful description. Please care for explaining, what you try and what you get as result. Post the code and the error messages, or explain the difference between the results and yopur expectations. It is not clear, what you want to achieve, because the currently posted code contains the creation of a function handle, although the examples in the documentation contains something completely different.
Start with the examples given in the documentation. Then modify these example stepwise until they match your needs. After each modification check, if the code is still running. If not, you know exactly, which modification does not match the needs.

Sign in to comment.