Matlab plots can display data-tips but these cannot be interactively moved except to the 4 corners of the data point.
This utility enables the user to interactively drag any newly-created data-tip, anywhere in the Matlab figure. A dashed line connects the dragged data-tip with the original data point.
The new draggable functionality only affects new data-tips, so it can be turned on/off to enable standard and new data-tips to co-exist in the same plot (see screenshot).
Syntax: draggableDataTips(newState)
Examples:
draggableDataTips('on') or draggableDataTips(true) turns the new functionality ON for new data-tips.
draggableDataTips('off') or draggableDataTips(false) turns the new functionality OFF for new data tips.
Warning:
Relies on undocumented functionality.
This utility fails in HG2 (R2014b+) - please don't bug me about it, unless you found a solution...
On HG2 (R2014b+), use Allen's submission: https://www.mathworks.com/matlabcentral/fileexchange/69799-dragdatatip
Technical description:
http://UndocumentedMatlab.com/blog/draggable-plot-data-tips
Yair Altman (2021). Draggable data tips (https://www.mathworks.com/matlabcentral/fileexchange/44065-draggable-data-tips), MATLAB Central File Exchange. Retrieved .
Inspired: DragDataTip
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Yair,
Just wanted to pass along a solution for allowing draggable data tips on newer versions of MATLAB (see attached link).
https://www.mathworks.com/matlabcentral/fileexchange/69799-dragdatatip
Aditya - a new version was just uploaded that fixes this minor problem.
Yair,
I like this a lot. Thanks.
I found what could be a bug:
- create a datatip
- drag it so that the dashed line appears
- click on the dashed line and an error appears and the datatip goes away.
This is in 2013b 64 bit.
Here is the error:
err =
Error using set
Invalid handle
No public field DataIndex exists for class handle.
Error in graphics.datacursor/default_updateDataCursor
(line 38)
hDataCursor.DataIndex = ind;
Error in graphics.datacursor/updateDataCursor (line 31)
hThis.default_updateDataCursor(hgObject,hDataCursor,target);
Error in graphics.datatip/update (line 22)
updateDataCursor(hNewDataCursor,hThis.Host,hNewDataCursor,target);
Error in datacursormode>localWindowButtonDownFcnDatatip
(line 781)
update(hDatatip);
Error in datacursormode>localWindowButtonDownFcn (line
617)
localWindowButtonDownFcnDatatip(fig,hTool,hTarget,doNewDatatip);
Error in hgfeval (line 63)
feval(fcn{1},varargin{:},fcn{2:end});
Error in uitools.uimode/modeWindowButtonDownFcn (line
114)
hgfeval(newButtonDownFcn,hFig,evd);
Error in
uitools.uimode/modeControl>localModeWindowButtonDownFcn
(line 160)
hThis.modeWindowButtonDownFcn(hFig,evd,hThis,newValue);
Error while evaluating figure WindowButtonDownFcn