setting transparancy of legend?

조회 수: 259 (최근 30일)
Micke Malmström
Micke Malmström 2017년 1월 12일
편집: Adam Danz 2024년 4월 30일
Is it possible to make the background of the legend be slighly transparent so that the lines behind it can be somewat visible?
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 1월 16일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Afiq Azaibi
Afiq Azaibi 2024년 4월 26일
편집: Adam Danz 2024년 4월 30일
Starting in R2024a, legend supports the ability to control the level of transparency with the BackgroundAlpha property. Below is a short example:
plot(magic(7));
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.

추가 답변 (3개)

alice
alice 2017년 6월 27일
In undocumented Matlab, you will find how to do it here: http://undocumentedmatlab.com/blog/transparent-legend.
  댓글 수: 3
Miquel
Miquel 2020년 1월 31일
Awesome, guys! Thanks :)
Hakon Haugnes
Hakon Haugnes 2023년 8월 17일
echo that: awesom

댓글을 달려면 로그인하십시오.


Ilja Maljutenko
Ilja Maljutenko 2021년 5월 19일
This solution seems to work in Matlab 2020 +
h_leg.BoxFace.ColorType='truecoloralpha';
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 2017년 1월 16일
편집: Walter Roberson 2017년 1월 16일
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
James Richard
James Richard 2019년 12월 17일
Any news on this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by