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

26 vues (au cours des 30 derniers jours)
Jack M
Jack M le 1 Juin 2023
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

Réponses (1)

Nithin Kumar
Nithin Kumar le 5 Juin 2023
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.

Catégories

En savoir plus sur Just for fun dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by