how to control the BackgroundAlpha of the text box

4 vues (au cours des 30 derniers jours)
lang
lang le 20 Août 2025
Commenté : Les Beckham le 22 Août 2025
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.

Réponse acceptée

Les Beckham
Les Beckham le 20 Août 2025
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 commentaires
lang
lang le 22 Août 2025
It works, thanks!
Les Beckham
Les Beckham le 22 Août 2025

You are quite welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by