How do I make stairs lines transparent?

7 views (last 30 days)
Sisi
Sisi on 9 May 2017
Commented: Walter Roberson on 10 May 2017
Hi all, I'm new to matlab and would be grateful for your help. I have two columns of data "m_53_rp100_rcp45" and "m_55_rp100". I have the code below to draw stairs lines. It gives the figure attached. I would like to make the red lines transparent so we can see the overlaps and black lines underneath.
figure
stairs(m_53_rp100_rcp45,':');
hold on
s = stairs(m_55_rp100,'r');
hold off

Answers (2)

Akira Agata
Akira Agata on 10 May 2017
Also, this link would be some help.
  1 Comment
Sisi
Sisi on 10 May 2017
Thank you Akira! I'm stuck on the same question as Walter - basically I don't know what to put in the x, y in the patch(x,y).My data basically contains two columns. Within each column data, i have 60,000 observations, each with a value between 1 and -1

Sign in to comment.


Walter Roberson
Walter Roberson on 10 May 2017
There is no transparency setting for stair objects (or for line plots in general.) If you are using R2014b or later (as is very likely since you are new to MATLAB) then in order to get transparency you would have to create patch objects that look like lines; see https://www.mathworks.com/matlabcentral/answers/103074-how-can-i-set-the-transparency-of-line-objects-in-matlab-7-14-r2012a
  2 Comments
Sisi
Sisi on 10 May 2017
Hi Walter, many thanks for your reply! I've been playing with the patchline function and what confuses me is what to input in the xs and ys. I tried to put in the range of my data but it didn't work. I also tried the .color command adding a 4th element which didn't seem to matter to the transparency of the lines. For your info, my data basically contains two columns. Within each column data, i have 60,000 observations, each with a value between 1 and -1. Thanks again!
Walter Roberson
Walter Roberson on 10 May 2017
stairs plots have to draw with x y in the form
[x1 x2 x2 x3 x3 x4 x4 ...],
[y1 y1 y2 y2 y3 y3 y4 ...]

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!