How to set transparency of stem plot (alpha) - is it even possible?

조회 수: 27 (최근 30일)
Jack M
Jack M 2023년 6월 1일
답변: Nithin Kumar 2023년 6월 5일
Hi everyone,
I am using the stem function and would like to set the transparency (or alpha) to values other than 1 for certain data points.
The code I am using is basic:
s = stem(x,y);
I have tried setting s.Color(4) = 0.5 but s.Color(4) is non-existent.
I have also tried: alpha(s,0.5)but I get the error:
Warning: The alpha command is not compatible with the specified objects.
Is there any way of setting the transparency in stem plots?
thank you

답변 (1개)

Nithin Kumar
Nithin Kumar 2023년 6월 5일
Hi Jack,
Kindly refer to the following example in which I am Adding the transparency by setting the "FaceAlpha" property to a value between 0 (completely transparent) and 1 (completely opaque) to the stem plot.
figure
data = [2 4 6 7 8 7 5 2]; %input data
stem(data) %creating stem plot of data
dim2 = [.74 .56 .1 .1]; %specifying the dimensions and position of the rectangle
annotation('rectangle',dim2,'FaceColor','blue','FaceAlpha',.2)
For more information regarding adding the transparency using stem function, kindly refer to the following documentation:
I hope this answer helps you.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by