Change opacity of Lines

Hello everyone
I want to change the opacity of lines I plotted in a figure in MATLAB. I read somewhere about alpha and facealpha commands but couldn't figure how to use them. Could somoene please tell me how to do this?
Regards Adi

 Accepted Answer

Walter Roberson
Walter Roberson on 24 Jul 2012

1 vote

It is not possible to set the transparency of lines.
The workaround is to use very thin patches instead of lines, as you can change the EdgeAlpha property for patch edges, or the FaceAlpha property of patch faces; see http://www.mathworks.com/help/techdoc/ref/patch_props.html

More Answers (1)

Royi Avital
Royi Avital on 29 Sep 2017

7 votes

In newer versions of MATLAB you can do that easily using the Color property of the line.
By default it is RGB array (1 x 3). Yet if you set it to RGBA (1 x 4) the last value is the alpha of the color.
Enjoy...

6 Comments

This was an excellent solution!
Spent half an hour to find a solution, here it is. Thank you!
Thank you!! I spent hours on this problem
goc3
goc3 on 17 Sep 2021
This question should be updated to have this as the selected answer!
this does not work on 2021a. bit of an embarassment for matlab
The following works in R2021b (64-bit, Windows). The last value changes the transparency:
'Color',[0 0.4470 0.7410 0.1]);

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Asked:

Adi
on 24 Jul 2012

Commented:

on 4 May 2022

Community Treasure Hunt

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

Start Hunting!