Hello, how could I fill a figure bounded by a curve?
2 views (last 30 days)
Show older comments
Andrea Astarita
on 14 Feb 2017
Commented: Jake Simmonds
on 1 Feb 2019
I have a quite complex plot and I would like to fill with colour the bounded areas I am trying to use area(x,y) function but it doesn't work... This is my script
if true
% code
figure()
hold on
for i=1:(2*n)
x=zeros(1,length(phi));
y=x;
r=x;
r=r_phi0(i)*exp(b*phi);
x=r.*cos(phi);
y=r.*sin(phi);
plot(x,y)
if (i>1 && mod(i,2)==0)
drawLine([r_phi0(i-1) 0],[r_phi0(i) 0]);
if mod(N,2)==0
drawLine([r_phiN(i-1) 0],[r_phiN(i) 0]);
else
drawLine([-r_phiN(i-1) 0],[-r_phiN(i) 0]);
end
end
area(x,y)
axis tight
end
end
This is what it plot without using area()...
thank you all.
0 Comments
Accepted Answer
Easwar Kumar Yarrabikki
on 14 Feb 2017
Hello Astarita,
You can use fill function in MATLAB. All you just need is X and Y axis data for both curves. I also wrote sample code you can play with your data.
fill([X data for line1',fliplr(X data for line 2')]',[(Y data for line 1', ... fliplr((Y data for line 2)')]','required color');
1 Comment
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!