invisible curves under filled area??

6 ビュー (過去 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 Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by