image thumbnail

DragDataTip

version 4.0 (7.81 KB) by Allen
Creates draggable data tips with custom labeling options on most 2-D plots. Custom labels options can also be applied to standard data tips.

337 Downloads

Updated 12 Aug 2019

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This function provides a solution to the limited positions allowed by standard MATLAB Data Tips on
most 2-D plots by replacing them with draggable versions when the plot's "Data Tips" mode is
toggled 'off'. Since standard data tips can only be moved to a position where one of its four
corners touches the chosen data point, this often obstructs portions of nearby graphed data.
Draggable data tips can be moved anywhere on the current axes, thus allowing better visibility of
the plot. Several visual features are used to reference the draggable data tip to its data point
and parent object. These include a connecting line between the data tip textbox and its
corresponding data point, and the data tip border will try to utilize the same line properties as
the target line object.

The varargin input argument allows the user to optionally customize the data tips labels. For
example X- and Y-value labels can be replace with something more descriptive such as 'Time' and
'Accel'. In addition to axis labels and when a plot legend is used, a header label can be added to
the data tip. Headers are added above the axis labels and match the target object's display name
as it appears in the legend. While the data tip header feature requires a legend to exist prior to
creation of the data tip, the legend can be deleted after creating the data tip and will not
effect the header label. If a legend does not exist when the data tip is created, the header
option is ignored.

Note that optional labels are applied to all axes on a single figure. However, it is still
possible to use different labels for multiple axes on a single plot. This is done by reapplying
the function with a new set of labels before creating additional data tips containing the new
labels.

An EXAMPLE section is provided in the function notes, but if you have questions or trouble using
this function, 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 (2021). DragDataTip (https://www.mathworks.com/matlabcentral/fileexchange/69799-dragdatatip), MATLAB Central File Exchange. Retrieved .

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

Inspired by: draggable, Draggable data tips

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!