How to add transparency to animatedline?

I have some animation in plot that I want to add transparency to, since I'm plotting multiple data with different color, and sometimes they overlap. I tried alpha(object, 0.5), where object is the object created by command animatedline. But then the warning shows that 'The alpha command is not compatible with the specified objects'.
Is there a way to make the animatedline objects transparent to an extent? Thanks.

 Accepted Answer

It turns out to be possible, but not documented. Instead of setting the Color property to an RGB triple, set it to a quad, a list of 4 numbers between 0 and 1, RGBA.

3 Comments

Hi Walter, I tried what you said by the following line:
curve_1 = animatedline('Color',[0,0,1,0.5],'LineWidth',4,'MaximumNumPoints',3,'Parent',hAxes_TrqSplitLogic,'Marker','o','MarkerFaceColor',[0,0,1,0.5],'MarkerEdgeColor','none','MarkerSize',8);
But I got the following error: Error using animatedline While setting property 'MarkerFaceColor' of class 'AnimatedLine': Color value must be a 3 element vector
It appears that MarkerFaceColor cannot be set to transparent that way. I will keep looking.
I figured out a java approach to find and set the MarkerFaceColor including an alpha component. Unfortunately, the alpha part does not "stick": as soon as it is set, it gets reset back to 1.0

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!