invisible curves under filled area??

조회 수: 4 (최근 30일)
Vahid
Vahid 2012년 3월 22일
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

답변 (2개)

Walter Roberson
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
Vahid
Vahid 2012년 3월 22일
unfortunately, there is no FaceAlpha property for area function :-(
Walter Roberson
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
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.
  댓글 수: 1
Vahid
Vahid 2012년 3월 22일
apparently the way you suggested works, but the only problem is that the use of set(pl1,'FaceAlpha',0.5) makes the axes invisible. Do you think if there is a solution to fix it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by