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

24 ビュー (過去 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 Center および File ExchangeJust for fun についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by