The present code is a Matlab function that provides programmatically generation of a custom made datatip on a given Matlab figure (e.g. 2D and 3D lines, 3D surfaces, etc.). The function is very suitable for dynamic (animated) plots. The user can:
1) set the datatip position anywhere on the plot via data indexes;
2) set a custom X, Y and Z datatip labels;
3) hold the previously placed datatips.
Two examples are given in order to clarify the usage of the function. For convenience, the input and output arguments are given in the beginning of the function.
Warning: One must uncomment the code line 55 for Matlab R2014a and earlier.
Hello, great function here. Just wanted to say that in order to prevent the text in all datatips from changing to match the newest str, I commented out line 55 (updateDataCursors(cursorMode)). This allowed me to put many different data tips with different text in each on the same plot. Not sure if this was the right way to do it, but it works quite well! Thank you for creating this function.
Hi Siddaharth! First of all, thank you for your interest in my submission! As I wrote in the file information form, please comment the function code line 53 for Matlab R2014b and later, this will solve the problem.
when I run the examples 1 and 2 I get an error in line 53.
Could you look into it?
Hi Philipp! My function use a matrix indexing and the indexes must be integers. If your main program pass the noninteger indexes to the function, you must round them beforehend.
thanks for this submission,
does a way exist for creating datatips at non-integer indices?
That option corresponds to the datacursormode object's property 'SnapToDataVertex', which may be switched off to allow for non-integer indices.
A new version of the code has been uploaded.