invisible curves under filled area??

6 visualizaciones (últimos 30 días)
Vahid
Vahid el 22 de Mzo. de 2012
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

Respuestas (2)

Walter Roberson
Walter Roberson el 22 de Mzo. de 2012
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 comentarios
Vahid
Vahid el 22 de Mzo. de 2012
unfortunately, there is no FaceAlpha property for area function :-(
Walter Roberson
Walter Roberson el 22 de Mzo. de 2012
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.

Iniciar sesión para comentar.


Amy
Amy el 22 de Mzo. de 2012
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 comentario
Vahid
Vahid el 22 de Mzo. de 2012
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?

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by