File Exchange

image thumbnail


version 1.2 (4.7 KB) by Allen

Allen (view profile)

Creates draggable data tips with custom labeling options on 2-D plots. Custom labels also work on default MATLAB Data Tips.


Updated 03 Jan 2019

View License

This function allows for the creation of draggable data tips when using 2-D plots by replacing
default MATLAB Data Tips currently on a plot axes. Since default MATLAB Data Tips stack on top of
existing plot data and only allow the user to move the data tip to a position where one of its four
corners touches the data point, this often times blocks segments of nearby data. Draggable
data tips allow the user to move it anywhere on the current axes, thus allowing better visibility
of important data. Reference to its original data point is maintained by adding a connecting line
between the data tip textbox to its corresponding data point.

Additionally, this function allows the user to provide custom X- and Y-value labels to replace the
default 'X' and 'Y' with something more descriptive (i.e. - 'Time' and 'Accel'), as well as a data
tip header. When the header feature is turned on and a legend exists on the target plot axes, a
text string is added above the X- and Y-value labels that matches the object display name(s) as
listed within the legend. This feature requires that a legend must first be added to the axes
before the draggable data tips are created, but does not rely on the legend remaining on the axes
after the data tips have been created.

In order to use this function, it must be assigned to @KeyPressFcn property for a figure. After
using the default MATLAB data cursor tool to place tips on a plot, turn off the Data Cursor Tool
and press 'Ctrl+M' to replace all default Data Tips currently on the specified axes with draggable
versions. The draggable data tips can be removed by pressing the 'delete' key.

To update the default MATLAB data tips with custom labels, this function must be applied to the
@UpdateFcn property of the DataCursorManager handle.

An EXAMPLE section is provided in the function notes for how to properly use this function. If you have questions or trouble implementing this function, please leave a comment below. Please rate it if have a chance; all feedback is welcome. Thanks and enjoy, but don't forget to also download Francois Bouffard's draggable.m function.

Cite As

Allen (2019). DragDataTip (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Chang hsiung



- Updated parsing of varargin.
- Fixed bug when applying custom data tip labels to default MATLAB Data Tips.


- Apply custom data tip labels to default MATLAB Data Tips before creating draggable versions.
- Fixed bug that prevented default (gca) assignment of hAx input when not provided.


Added Acknowledgements

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

Inspired by: draggable, Draggable data tips

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor