Graph colouring

13 Ansichten (letzte 30 Tage)
old_user_rat
old_user_rat am 17 Apr. 2012
Dear all,
I have the following 2d plot. I would like to colour/shade the regions of the graph in the same way you would use the colour fill for shapes in a basic paint program. Is there an easy way to do this with code or in the plot editor?
Thanks, David
p=0:0.001:0.25;
y3=(p + (1 - 4*p).^(1/2)/2).^2/2;
plot(p,y3,'black')
hold all
y5=(1/2)*(p+(1/2)*(1-4*p).^(1/2)).^2;
plot(p,y5,'black')
hold all
p=0:0.001:0.5;
y1=2*p.^2;
plot(p,y1,'black')
hold all
y7=p.^2;
plot(p,y7,'black')
hold all
y2=(p-1/2).^2;
plot(p,y2,'black')
hold all
vline([((2)^(1/2)-1)/2,1/4],'black')

Antworten (1)

Thomas
Thomas am 17 Apr. 2012
One way: You could try an area plot with different colors and a transparency
p=0:0.001:0.25;
y3=(p + (1 - 4*p).^(1/2)/2).^2/2;
area(p,y3,'FaceColor','blue')
hold all
y5=(1/2)*(p+(1/2)*(1-4*p).^(1/2)).^2;
area(p,y5,'FaceColor','green')
hold all
p=0:0.001:0.5;
y1=2*p.^2;
area(p,y1,'FaceColor','red')
hold all
y7=p.^2;
area(p,y7,'FaceColor','cyan')
hold all
y2=(p-1/2).^2;
area(p,y2,'FaceColor','yellow')
hold all
alpha(0.5)
vline([((2)^(1/2)-1)/2,1/4],'black')

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by