Easy way to make text semitransparent?
Mostrar comentarios más antiguos
Hi all,
Is there an easy way to make text semitransparent in MATLAB? For instance, if I wanted a textbox label on a graph to be only partially transparent, is there any property to adjust, similar to 'AlphaData' for images?
Thanks!
1 comentario
Sebastian
el 27 de Nov. de 2017
You could change the color of the text by 'color',[0.8,0.8,0.8]
It's not transparent but assuming that you have a white background it is slightly grey to white and looks transparent.
Respuesta aceptada
Más respuestas (1)
Matthias Luh
el 3 de Mayo de 2019
Well, not exactly transparent I guess. But if your plot window is white, you could brighten the font up, so it looks transparent...
my_color = [0 0 1]; % [r g b] => blue
text(2, 1, 'normal text', 'Color', my_color);
opacity = 0.4; % 40 percent visible = mainly transparent
text(2, 1.5, 'kinda transparent text', 'Color', (1 - opacity * (1 - my_color)));
I'm sure someone will also find a way for non-white backgrounds...
2 comentarios
Sebastian Lopez
el 6 de Mayo de 2022
Works great. Thank you!
Giovanni Barbarino
el 20 de Feb. de 2023
for non white bachground you can just take the color of the background and do a convex combination with the text color.
probably something like
f_color = get(gcf,'Color')
Categorías
Más información sobre Lighting, Transparency, and Shading en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!