Transparency coating

I need to build two curves, as shown below, that overlap each other. How can I make the overlapping area transparent so that the bottom curve is visible? In the overlap area, I can only see the upper curve.

x=0:0.01:2*pi;                  %#initialize x array
y1=sin(x);                      %#create first curve
y2=sin(x)+.5;                   %#create second curve
X=[x,fliplr(x)];                %#create continuous x value array for plotting
Y=[y1,fliplr(y2)];              %#create y values for out and then back
fill(X,Y,'b');                  %#plot filled area
%*****************
hold on
x=0:0.01:2*pi;                  %#initialize x array
y1=sin(2.*x);                   %#create first curve
y2=sin(2.*x)+.5;                %#create second curve
X=[x,fliplr(x)];                %#create continuous x value array for plotting
Y=[y1,fliplr(y2)];              %#create y values for out and then back
fill(X,Y,'b');                  %#plot filled area
+2
source share
1 answer

Replace the last command fill(X,Y,'b');with:

h = fill(X,Y,'b');

to get the handle to the created patch object. Then enter:

set(h, 'FaceAlpha', 0.5)

enter image description here

Does it do what you need?

+3
source

Source: https://habr.com/ru/post/1720673/


All Articles