Data Tips -- Add Row Error
38 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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),...
yes(index).yeehaw(:,3));
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 matlab.graphics.datatip.DataTipTemplate/set.DataTipRows. 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?
0 comentarios
Respuestas (2)
Scotty Neally
el 19 de Jun. de 2020
I had similar issues but was able to debug them.
They key is that any text you try to put into the new datatip field (ie row 3) must be a cell array of strings the same size as the other 2 rows (XData and YData) because the textbox displays the contents at whatever index the datatip is at.
Example of my implimentation in App Designer:
row = dataTipTextRow('yes or yeehaw',repmat({'yeehaw'},numel(XData),1)); %Creates a string cell the size of XData
H.Children(1).DataTipTemplate.DataTipRows(end+1) = row; %H.Children(1) is handle to plot line
0 comentarios
Jan
el 10 de Jun. de 2019
Did you read the example https://www.mathworks.com/help/matlab/creating_plots/create-custom-data-tips.html and https://www.mathworks.com/help/matlab/ref/matlab.graphics.datatip.datatiptextrow.html ?
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.
2 comentarios
Jan
el 11 de Jun. de 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.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!