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

19 次查看(过去 30 天)
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