绘制透明度

时间:2014-04-22 08:31:50

标签: matlab

我必须绘制两条相互重叠的曲线。如何使重叠区域透明,以便可以看到下面的曲线?在重叠区域,我目前只能看到顶部曲线。

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

1 个答案:

答案 0 :(得分:3)

将上一个命令fill(X,Y,'b');替换为:

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

获取它创建的补丁对象的句柄。然后输入:

set(h, 'FaceAlpha', 0.5)

enter image description here

这样做你需要的吗?