透明绘图 [英] Plotting with transparency
本文介绍了透明绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须绘制以下两条相互重叠的曲线.如何使重叠区域透明,以使下部曲线可见?在重叠区域中,我目前只能看到顶部曲线.
I have to plot two curves as below that overlap each other. How I can make the overlapping area transparent, in order that the lower curve is visible? In the overlapping area, I can currently only see the top 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
推荐答案
将上一个命令fill(X,Y,'b');
替换为:
h = fill(X,Y,'b');
获取其创建的补丁对象的句柄.然后输入:
to get a handle to the patch object it creates. Then type:
set(h, 'FaceAlpha', 0.5)
那是您需要的吗?
这篇关于透明绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文