フィルターのクリア

Shading area under the curve

193 ビュー (過去 30 日間)
Youngmin
Youngmin 2020 年 5 月 16 日
コメント済み: Youngmin 2020 年 5 月 16 日
Hello,
I am struggling with shading area under the curve at the selected area. I wanted to fill the area over Body Weight line. I have attached my code and the screenshot of the plot.
x = 0:2500;
Lvy = (611 <= x)&(vgrf2 >= bw) & (x < 794);
figure(1)
plot(x,vgrf2,'k')
hold on;
xline(lcom,'k--','Lowest COM position','LabelHorizontalAlignment','center',...
'LabelOrientation','horizontal');
yline(bw,'k--',{'Body','Weight'},'LabelHorizontalAlignment','left',...
'LabelVerticalAlignment','middle');
patch([x(Lvy) fliplr(x(Lvy))], [ones(size(x(Lvy))) fliplr(vgrf2(Lvy))], 'g')
hold off;
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 16 日
Can you attach your data for testing?
Youngmin
Youngmin 2020 年 5 月 16 日
I have attached the sample.mat file on the original post. Also, BW is 762.6170, and lcom is 611.

サインインしてコメントする。

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 5 月 16 日
編集済み: Mehmed Saad 2020 年 5 月 16 日
Use area for that purpose by selecting the specific range and use area
x = 0:2500;bw =700;lcom = 611;
Lvy = (611 <= x)&(vgrf2 >= bw) & (x < 794);
figure(1)
plot(x,vgrf2,'k')
hold on;
xline(lcom,'k--','Lowest COM position','LabelHorizontalAlignment','center',...
'LabelOrientation','horizontal');
yline(bw,'k--',{'Body','Weight'},'LabelHorizontalAlignment','left',...
'LabelVerticalAlignment','middle');
selected_area = lcom:793;
area(selected_area,vgrf2(selected_area),bw,'EdgeColor','none','FaceColor','g')
Also to select all the area ahead of this point which is greater than bw in y and lcom in x
load('sample.mat')
x = 0:2500;bw =700;lcom = 611;
figure(1)
plot(x,vgrf2,'k')
hold on;
xline(lcom,'k--','Lowest COM position','LabelHorizontalAlignment','center',...
'LabelOrientation','horizontal');
yline(bw,'k--',{'Body','Weight'},'LabelHorizontalAlignment','left',...
'LabelVerticalAlignment','middle');
ind = (vgrf2>bw)&x>lcom;
vgrf2(~ind) = NaN;
area(x,vgrf2,bw,'EdgeColor','none','FaceColor','g')
  6 件のコメント
Mehmed Saad
Mehmed Saad 2020 年 5 月 16 日
編集済み: Mehmed Saad 2020 年 5 月 16 日
set the ShowBaseLine property of area to off
area(x,vgrf2,bw,'EdgeColor','none','FaceColor','g','ShowBaseLine','off')
Youngmin
Youngmin 2020 年 5 月 16 日
Thank you. it works very well!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by