This function provides a solution to the limited positions allowed by standard MATLAB Data Tips on
most 2-D plots by replacing them with a draggable version when the "Data Tip" mode is toggled off.
Since standard data tips can only be moved to a position where one of its four corners touches the
selected data point, this can unavoidably lead to obstructed portions of graphed data. Draggable
data tips can be moved anywhere within the current axes, thus allowing better visibility of the
plot. New visual features are used to reference the draggable data tip to its corresponding data
point and parent object. These include a connecting line between the data tip textbox and the data
point as well as a border on the data tip that will try to utilize the same color and line weight
properties as the target parent 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.
Additional variable input options include setting the numerical precision and/or font size for the
displayed data values, and adjusting the appearance of the leader lines by specifying the line
While the labels/header options are applied to all axes within a single figure, it is
still possible to use different labels and headers throughout multiple axes or even on a single
axes for a figure. This is done by applying DRAGDATATIP to a figure and adding a number of new
draggeble data tips, then reapplying DRAGDATATIP with a new set of options and creating additional
NOTE: Draggable data tips can currently be removed by using one of the methods listed below:
1. Right-click on any single data tip and select delete single or all from the context menu.
2. Use the figure's "Edit Plot" tool, select the data tip, and press 'delete'.
3. Find and delete axes line objects with the "Tag" property set to 'DraggableDataTip'.
DRAGDATATIP relies heavily on undocumented features and functions in MATLAB.