DragDataTipMode

バージョン 1.0.0.1 (10.9 KB) 作成者: Allen
A custom class definition that replaces standard data tips with draggable versions in order to maintain a clear view of all plot data.
ダウンロード: 7
更新 2023/6/4

ライセンスの表示

DRAGDATATIPMODE objects are used to create/manage replacements to standard MATLAB data tips that allow the the user to drag them to a more desirable location within their parent axes. This behavior was developed as a solution to the limited movement of standard data tips, which can only be repositioned with one of their four corners directly attached to their target data point. The limited movement of standard data tips often resulted in portions of the plotted data being blocked from view by the data tip. DRAGTIPOBJ objects use a thin leader-line to maintain a visible connection to their target data point and be moved to a position that does not obsure other sections of data. To remove/delete DRAGTIPOBJ objects, right-click on any single data tip and select delete single or all from the context menu.
Additionally, the appearance of the DRAGTIPOBJ can be customized by changing the fontsize, adding headers to include a target's DisplayName, change the line style of the leader-line, change the precision of enumerated data shown, and/or change the X- and Y-labels.
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 DRAGDATATIPMODE to a figure, adding data tips, toggling the data-cursor mode off to convert them to DRAGTIPOBJ objects, then reapplying DRAGDATATIPMODE with a new set of options and creating additional data tips.
DRAGDATATIPMODE and DRAGTIPOBJ objects were designed to work with LINEVISIBLE, that uses a legend's 'ItemHitFcn' callback function to toggle the visibility of plot items. The visibility of a DRAGTIPOBJ is tied to its target plot item. See the Examples section on how to link this visibiltiy behavior using LINEVISIBLE.
Their are currently some limitations to the types of MATLAB plots and data types that DRAGTIPOBJ objects can be used with, but will work with the majority of 2-D plots that already support data tips and for most enumerated data types. It is intended for future versions to function with all plot and data types for which MATLAB already provides data tip functionality.
This class of variable is also a HANDLE-class, which limits its existance to a single instance. See Examples section for more details.
DRAGDATATIPMODE and DRAGTIPOBJ rely on undocumented features and functions in MATLAB.
EXAMPLES:
Create a figure, plot 'peaks', and assign DRAGDATATIPMODE to the current figure's axes.
hFig = figure;
plot(peaks);
grid on
title('Draggable Data Tips')
xlabel('Data Index Values')
ylabel('Acceleration (g''s)')
DragDataTipMode
Include optional x- and y-axis labels for the data tips, turn on the headers, and specify the display precision for data tip values, font size, and leader line style.
hFig = figure;
hLin = plot(peaks);
grid on
title('Draggable Data Tips with Customizable Labels')
xlabel('Data Index Values')
ylabel('Acceleration (g''s)')
lgtxt = arrayfun(@(a) ['Line #',num2str(a)],1:length(hLin),'un',0)';
legend(lgtxt,'Orientation','horizontal','NumColumns',10,'Location','best')
DragDataTipMode(hFig,'xlabel','Index','ylabel','Accel','header','on','fontsize',16,'linestyle',':',...
'precision','%0.3g')
Link the DRAGTIPOBJ visibility to its target item and set assign to the axes legend's 'ItemHitFcn'
hFig = figure;
hLin = plot(peaks);
grid on
title('Draggable Data Tips with Customizable Labels')
xlabel('Data Index Values')
ylabel('Acceleration (g''s)')
DragDataTipMode(hFig,'xlabel','Index','ylabel','Accel','header','on')
lgtxt = arrayfun(@(a) ['Line #',num2str(a)],1:length(hLin),'un',0)';
LineVisible(legend(lgtxt,'Orientation','horizontal','NumColumns',10,'Location','best'))

引用

Allen (2024). DragDataTipMode (https://www.mathworks.com/matlabcentral/fileexchange/130559-dragdatatipmode), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2023a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
謝辞

ヒントを得たファイル: DragDataTip, LineVisible

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.1