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.

 Respuesta aceptada

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 comentarios

lang
lang el 22 de Ag. de 2025
It works, thanks!

You are quite welcome.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Text Analytics Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2025a

Etiquetas

Preguntada:

el 20 de Ag. de 2025

Comentada:

el 22 de Ag. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by