DragDataTip

Version 4.7.9.15 (9,41 KB) von Allen
Creates draggable data tips with custom labeling options on some 2-D plots. Custom labels options can also be applied to standard data tips.
689 Downloads
Aktualisiert 4. Jun 2023

Lizenz anzeigen

Anmerkung des Herausgebers: 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 some 2-D plots by replacing them with draggable versions 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 options input argument allows the user to 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 style.
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, adding data tips, toggling the data-cursor mode off to convert them to draggable data tips, then reapplying DRAGDATATIP with a new set of options and creating additional data tips.
DRAGDATATIP relies heavily on undocumented features and functions in MATLAB.

Zitieren als

Allen (2024). DragDataTip (https://www.mathworks.com/matlabcentral/fileexchange/69799-dragdatatip), MATLAB Central File Exchange. Abgerufen.

Kompatibilität der MATLAB-Version
Erstellt mit R2023a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Legend finden Sie in Help Center und MATLAB Answers
Quellenangaben

Inspiriert von: draggable, Draggable data tips

Inspiriert: DragDataTipMode, LineVisible

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
4.7.9.15

Minor code improvements. Likely to be the last version and will be replaced by DRAGDATATIPMODE and DRAGTIPOBJ classes. These new class objects will provide the same functionality, but work over a greater range of plot and data types.

4.6

Minor refinements to improve stability and performance.

4.5

Bug Fixes

4.4

-Minor bug fixes and removed unused/redundant code.
-Suppressed warning messages.
-Data tips are deleted when their associated parent objects are deleted.
-Link "Visible" properties between data tip and parent object.

4.3

Fixed bug related to CreateFcn use and improved overall speed (less lag when dragging data tips). Also added behavior improvements related to figure resizing, axes limit changes, object stack order, and figure visibility for opening saved figures.

4.2

Added additional optional customization features, removed dependency of the figure's KeyPressFcn, and updated the CreateFcn callback to maintain DragDataTip functionality when saving and then reopening a figure.

4.0

- Incorporate draggable() directly into code to address multiple issues
- Works with datetime data classes
- Fixed bug on log-scales
- Added more data tip deletion opts
- Fixed bugs associated with various 2-D plot types (scatter,area,bar,etc.)

3.2

- Fixed bug to apply function to multiple figures simultaneously.
- Fixed bug to work with 'duration' data types
- Added non-draggable display fixes for 'date/times'. Requires update to draggable.m to make 'date/times' draggable.

3.1

-Added 'on/off' option to the draggable feature. Allows header and labels to be applied to standard data tips.

3.0

- Now works with a single line of code.
- Assigns function to the current figure when the 'hFig' input is not used.
- Improved data tip deletion methods.
- Fixed bug that allowed data tips to be applied to existing data tip leader lines.

2.0

- Changed function behavior to utilize a property listener on the DataCursorManager "Enable" property. This allows toggling of the DataCursorMode between 'on' and 'off' to create the draggable data tips vs the previous need to use the "KeyPressFcn".

1.2

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

1.1

- 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.

1.0.1

Added Acknowledgements

1.0