MATLAB Answers

Vahid
0

invisible curves under filled area??

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

  0 件のコメント

サインイン to comment.

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
2012 年 3 月 22 日
unfortunately, there is no FaceAlpha property for area function :-(
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.

サインイン to comment.


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
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?

サインイン to comment.



Translated by