Filter löschen
Filter löschen

Easy way to make text semitransparent?

39 Ansichten (letzte 30 Tage)
Jared
Jared am 23 Jan. 2013
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 Kommentar
Sebastian
Sebastian am 27 Nov. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 23 Jan. 2013
Unfortunately No. You have to convert the text to a bitmap and display it as an image (or surface) with appropriate transparency.
There are contributions in the FEX to assist with converting text to image.
  3 Kommentare
Matthias Luh
Matthias Luh am 19 Mär. 2022
It is crazy to see that this is still an issue in 2022... :(
Voss
Voss am 19 Mär. 2022
Lots of things are crazy.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Matthias Luh
Matthias Luh am 3 Mai 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 Kommentare
Sebastian Lopez
Sebastian Lopez am 6 Mai 2022
Works great. Thank you!
Giovanni Barbarino
Giovanni Barbarino am 20 Feb. 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')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by