Filter löschen
Filter löschen

setting transparancy of legend?

285 Ansichten (letzte 30 Tage)
Micke Malmström
Micke Malmström am 12 Jan. 2017
Bearbeitet: Adam Danz am 30 Apr. 2024
Is it possible to make the background of the legend be slighly transparent so that the lines behind it can be somewat visible?
  1 Kommentar
Walter Roberson
Walter Roberson am 16 Jan. 2017
I will not say that it is impossible at the moment. It is certainly not documented. You just might be able to change it using one of the hidden properties of the legend. Perhaps one of the ColorSpace properties. Nothing I have tried has worked yet.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Afiq Azaibi
Afiq Azaibi am 26 Apr. 2024
Bearbeitet: Adam Danz am 30 Apr. 2024
Starting in R2024a, legend supports the ability to control the level of transparency with the BackgroundAlpha property. Below is a short example:
grid on;
set(gca, 'Color', [.88 .88 .88]);
l = legend(BackgroundAlpha=.7);
Setting the value to 0 will make it fully transparent and a value 1 of will make it fully opaque which is the default behavior.
Rectangle also has a new FaceAlpha property and you can read more about both in this blog post.
Other answers in this thread address solutions prior to R2024a.

Weitere Antworten (3)

alice am 27 Jun. 2017
In undocumented Matlab, you will find how to do it here:
  3 Kommentare
Miquel am 31 Jan. 2020
Awesome, guys! Thanks :)
Hakon Haugnes
Hakon Haugnes am 17 Aug. 2023
echo that: awesom

Melden Sie sich an, um zu kommentieren.

Ilja Maljutenko
Ilja Maljutenko am 19 Mai 2021
This solution seems to work in Matlab 2020 +
h_leg.BoxFace.ColorData=uint8(255*[1 1 1 0.75]');
where h_leg is your legend box handle.

Wilson A N
Wilson A N am 16 Jan. 2017
Bearbeitet: Walter Roberson am 16 Jan. 2017
You can refer to the link given below on how to set the different properties of legend
To change the background color of the legend you can change the 'Color' field to achieve the required transparency.
  3 Kommentare
James Richard
James Richard am 17 Dez. 2019
Any news on this?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by