invisible curves under filled area??
3 次查看(过去 30 天)
显示 更早的评论
Hi everybody,
I am wondering whether there is a way to have a filled area 2D plot without affecting other curves under it so that after plotting filled area I can still see the curves under the filled area, e.g. in the following example area command results in disappearing the curve under it:
x=5:0.1:10;
y0=0.75*exp(sqrt(x));
y1=1*exp(sqrt(x));
hold on
pl0=plot(x,y0);
pl1=area(x,y1);
set(pl1,'FaceColor',[0 0.5 0.5],'EdgeColor','none');
xlim([0,15]);
ylim([0,30]);
hold off
I know that if I reorder the plot and area functions, I can have both the curve and the filled area (the curve becomes visible in the filled area) , but I do not want to reorder them. I am looking for a solution to control area function as if it does not make the curves under it invisible.
Thanks in advance, --V
0 个评论
回答(2 个)
Walter Roberson
2012-3-22
area(...,'PropertyName',PropertyValue,...) specifies property name and property value pairs for the patch graphics object created by area.
So look at the patch properties documentation and see that there is a FaceAlpha property; you can pass a value for that property in the area() call.
2 个评论
Walter Roberson
2012-3-22
Beh, inconsistent documentation. I suspect there is a solution by looking at the children of the areaseries objects, but I cannot test that at the moment.
Amy
2012-3-22
The easiest way is to reorder the code to plot the filled area first. Without reordering the code, I couldn't find a way to do keep the line visible using the function area, but perhaps you could use patch. You replace pl1=area(x,y1); with the following:
pl1 = patch([x x(end) x(1)],[y1 0 0],'b'); set(pl1,'FaceAlpha',0.5)
This basically makes the filled area slightly transparent so you can see what is below. The handle for area does not have a FaceAlpha property.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!