How can I remove the tooltip from the exported figure?

3 ビュー (過去 30 日間)
y w
y w 2023 年 10 月 25 日
コメント済み: y w 2023 年 11 月 3 日
I'm facing the issue where the exported .png files contain the pop up message of 'Click legend labels to toggle the line visibility'.
To elaborate, there are two figures generated and saved separately as follows:
set(gcf,'position',[100,100,1000,800]);
filepath = 'xxx';
filename = 'Sample 11-1 rep S11 magnitude';
figname_write = strcat(filepath,filename);
print(figname_write,'-dpng','-r0');
set(gcf,'position',[100,100,1000,800]);
filepath = 'xxx';
filename = 'Sample 11-1 rep S11 phase';
figname_write = strcat(filepath,filename);
print(figname_write,'-dpng','-r0');
The issue only happens to the first figure and not the second one, where the outcome looks like this (the yellow bar up top):
I tried to disable the interactivity with:
legendItems = findall(leg, '-property', 'ItemHitFcn');
set(legendItems, 'ItemHitFcn', '');
and it worked, but it seems like a temporary solution, as in this would have to added in every piece of code in the future to prevent the error and it is going to be a hassle. I'd like to know more about :
  • Why the image export process captures this popup message
  • How to solve this issue permanently, whether there's any setting in the preference I can adjust to make it go away.
Thanks!

採用された回答

Benjamin Kraus
Benjamin Kraus 2023 年 10 月 30 日
This banner should only appear when you first move your mouse over the figure, and it should only remain visible for 5 seconds.
So, the easiest approach to avoid the banner in your exported images would be to:
  • Avoid moving your mouse over the figure before exporting.
  • Or wait at least 5 seconds after moving your mouse over the image before exporting.
If neither of those are acceptable solutions, it appears you can disable the banner like this:
setappdata(gcf,'ShownInteractiveBehaviorBanner',true);
  1 件のコメント
y w
y w 2023 年 11 月 3 日
This works for me. Thanks for the clarifying the mechanism and sharing the command Benjamin!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by