Issues with area function to fill under plot
1 回表示 (過去 30 日間)
古いコメントを表示
Consider the following code:
xData = rand(100,1)*0.5;
yData = linspace(2000,2500,100);
figure(1)
plot(xData,yData)
which produce the following figure (after resizing it slightly horizontally):
Now, I want to basically fill the area under the curve, i.e. between x=0 and the curve. So, when I try the area function:
figure(2)
area(xData,yData)
I get the following figure (which is obviously not what I want):
What am I doing wrong?
0 件のコメント
採用された回答
Star Strider
2017 年 10 月 19 日
Try this:
y = 0:20;
x = rand(size(y));
figure(1)
plot(x, y)
hold on
patch([ zeros(size(x)) x ], [ fliplr(y) y ], 'g')
hold off
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!