How do I pre-select the "Data Tips" button when creating figure?

2 ビュー (過去 30 日間)
mahaju
mahaju 2023 年 10 月 16 日
編集済み: Rik 2023 年 10 月 16 日
How do I pre-select the data tips button when a figure is created? Currently I need to hover the mouse cursor over the figure for the buttons to show up then manually click the data tips button.
How do I make this happen automatically, when the figure is created? What is the general method to programmatically pre-click any of the button shown here?
Matlab version: 9.11.0.1873467 (R2021b) Update 3
  4 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 10 月 16 日
Do you have specific points you want to have the data-tip for?
mahaju
mahaju 2023 年 10 月 16 日
@Dyuman Joshi No I just want that data tip button already pressed when the figure is created

サインインしてコメントする。

採用された回答

Pratyush
Pratyush 2023 年 10 月 16 日
Hi mahaju,
I understad that you want to select the programmatically the buttons present in the toolbar (specifically Data Tip).
‘findall’ function could be used to get handle of the Toolbar in the figure. Then you can use that handle to access any button on the Toolbar. You can refer to the following documentation for more details on findall: Find all graphics objects - MATLAB findall - MathWorks India
The following script can help you with that:
%Get handle to Toolbar
>> toolbar = findall(f,'Type','ToolBar')
toolbar =
10×1 graphics array:
ToolbarStateButton (Brush Data)
ToolbarStateButton (Data Tips)
ToolbarStateButton (Rotate 3D)
ToolbarStateButton (Pan)
ToolbarStateButton (Zoom In)
ToolbarStateButton (Zoom Out)
ToolbarPushButton (Restore View)
ToolbarPushButton (Save As)
ToolbarPushButton (Copy as Image)
ToolbarPushButton (Copy as Vector Graphic)
%Get handle to Data Tip
>> datatip = toolbar(2)
datatip =
ToolbarStateButton (Data Tips) with properties:
Tooltip: 'Data Tips'
Icon: 'datacursor'
ValueChangedFcn: @(e,d)datacursormode(ancestor(d.Source,'figure'),d.Value)
Show all properties
%Toggle Data Tip between on and off
>> datatip.set('Value','on')
  3 件のコメント
Rik
Rik 2023 年 10 月 16 日
編集済み: Rik 2023 年 10 月 16 日
That looks like it should be the handle to the figure.
Note that you can adapt this code to already select the correct element:
DataTipToolbarElement = findall(f,'Type','ToolBar','Tooltip','Data Tips');
DataTipToolbarElement.set('Value','on')
mahaju
mahaju 2023 年 10 月 16 日
@Dyuman Joshi figure handle, or gcf

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by