File Exchange

image thumbnail

Programmatically Datatip Generation with Matlab Implementation

version (2.27 KB) by Hristo Zhivomirov
Programmatically generation of a custom made datatip on a given Matlab figure.


Updated 28 Dec 2017

View License

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.

Cite As

Hristo Zhivomirov (2020). Programmatically Datatip Generation with Matlab Implementation (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

I plot two curves in one figure with different plot handles. So I want to make a datatip at curve one with a special string text one
(for example {'Frequenz/GHz=','|\rho_B|^2/dB='})
and an other datatip at the curve two with an other string text
(for example {'Frequenz/GHz=','|\tau_B|^2/dB='})
If I use your program datatip twice(the seond with the 'hold' option), the first string were overwritten by the last one.
So both datatips have the same text, but the true x,y values.
Do you see a possibility to overcome this problem.
Kind regards Siegfried



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.

All best,
Hristo Zhivomirov

Hi there,
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.

Best regards,
Hristo Zhivomirov



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.

Kind regards,


A new version of the code has been uploaded.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: MAKEDATATIP