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

27 visualizaciones (últimos 30 días)
Jack M
Jack M el 1 de Jun. de 2023
Respondida: Nithin Kumar el 5 de Jun. de 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

Respuestas (1)

Nithin Kumar
Nithin Kumar el 5 de Jun. de 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.

Categorías

Más información sobre Just for fun en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by