how to control the BackgroundAlpha of the text box

Is there a way to create a text box with BackgroundAlpha (such as 0.5)? I can't find the alpha option for text box background in Text Properties.

 採用された回答

Les Beckham
Les Beckham 2025 年 8 月 20 日

0 投票

You can use the undocumented feature of a 4-element color spec (the fourth element is the alpha). For example:
plot([0 1], [0 1]);
ht = text(0.45 ,0.5, 'This is a test');
set(ht, 'EdgeColor', [0 0 0], 'BackgroundColor', [1 0 0 0.4]);

2 件のコメント

lang
lang 2025 年 8 月 22 日
It works, thanks!
Les Beckham
Les Beckham 2025 年 8 月 22 日

You are quite welcome.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Analytics Toolbox についてさらに検索

製品

リリース

R2025a

タグ

質問済み:

2025 年 8 月 20 日

コメント済み:

2025 年 8 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by