【问题标题】:Plotting with transparency透明绘图
【发布时间】:2014-06-06 12:30:43
【问题描述】:

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

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

【问题讨论】:

    标签: matlab


    【解决方案1】:

    将您的最后一条命令 fill(X,Y,'b'); 替换为:

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

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

    set(h, 'FaceAlpha', 0.5)
    

    这能满足你的需要吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-14
      • 2010-11-25
      • 2021-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-19
      相关资源
      最近更新 更多