File Exchange

image thumbnail


version (7.34 KB) by Michelle Hirsch
Interactive labeling of data points on a plot.


Updated 01 Sep 2016

View License

This is an interactive data label. Just click on a point on a plot to see it's value. Drag the point around to see how the value changes. Click at another location to add a new label.
I build this back in the day before MATLAB had data tips. I'd recommend starting with them first before seeing if you like this one better (click on the button just to the right of rotate on the figure toolbar).

Comments and Ratings (23)

Ella - Just update this line of code (line 89):

th = text(xv,yv,[' (' num2str(xv) ',' num2str(yv) ')']);

This is the command that generates the text that is displayed. If you wanted to just show a raw x value, for instance, you could change it to:

th = text(xv,yv,num2str(xv));

Hello, How can I do to display only the x label

it'll be really great if this function can be put in plot toolbar alongside data cursor.
The benefit of this function is that you can get row index of your data and timestamp if you like which really helps in data analysis.


Great file. I made a simple modification to output indices rather than coordinates. T This way I can identify the interesting points on a scatter plot and investigate them.

Robert Daly

For time series data you can get the 'x coordinate' as a date string by changing line 89 to ...
th = text(xv,yv,[' (' datestr(xv) ',' num2str(yv) ')']);

When you click on a feature it will tell you when it happened as a date and time rather than a cryptic matlab date number. One area where Excel seems to be better than Matlab (until now!).


Dear all,
I have a curve in 2d. Every point of this curve is correspond to another rows of a (n,3) matrix.
Is it possible with "datalabel" or do you know any other hint?

Juan Pedro


Akshay B

Awesome!! Thanks!

Engin Masazade

Very useful, thanks a lot

ma r

Thank you so much. This is perfect.

Elias Bwick

Thanks dude. This is exactly what I was looking for. Excellent

Zhichao Ruan

great job

Mo saggaf

Mo saggaf

Zahid Ullah Khan

Its Great... Thanks :-]

Keven Chang

Great Great Job.

More, Is possible to have a transparent.
Back Ground.

Andrey Loginov

Cool and easy to upgrade!
If you wish to get optional label backgrounds, text size, text color&style or even optional label position simply change input, store additional fields with "setappdata" and get them further with "getappdata".
It is also not difficult to modify code to get labels in between of XY line data points:).

Wong Yew Leong

Cool...just what we wanted!

Mujahid Sultan

Simply superb! great work.

YaYa Huang

You are an excellent guy!!

Luc Jonckheere


Lina Chang

This added feature is great! I've always wanted to be able to this to my plots.

Josef Nauderer

Usefull tool!!!!


Updated license

Cleaned up title

Made available as an easy-to-install Toolbox file.

Removed mistaken attribution

Update copyright

Bug fix: Now works on horizontal lines. Thanks to Robert Young for catching this and fixing the code!

Add telemetry keyword.

The text labels can now be moved relative to the data markers. This makes it easier to read labels that might have been obscured by other data.

Through discussions with our developers, I realized that this file has the same name as a file that will be included in R13 (the capabilities are different). Would it be possible to change the name to datalabel?

Thanks, Scott

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: scattertext