Graph colouring
Show older comments
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')
Answers (1)
Thomas
on 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')
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!