フィルターのクリア

How to fill the area under the curve ?

26 ビュー (過去 30 日間)
C.PR
C.PR 2023 年 6 月 7 日
コメント済み: Star Strider 2023 年 6 月 7 日
Hi all,
I am currently doing a 3D figure with 3 differents 2D-plots (representing 3 conditions)
1) How can I fill the area under the ploted curves ? It is currently filling the area from the top of the curve up to a random horizontal axis
I previously used the fliplr tool but does not work at the moment here ...
2) How can I invert the y-axis (currently going from 100 to 0, and needs to be from 0 to 100)
Thanks a lot
figure
y = Data{:,1};
z = Data{:,2};
x = Data{:,3};
fill3(x,y,z,[0.00,0.45,0.74],'LineStyle','none','FaceAlpha',.3)
hold on
y = Data{:,1};
z = Data{:,4};
x = Data{:,5};
fill3(x,y,z,[0.04,0.49,0.35],'LineStyle','none','FaceAlpha',.3)
hold on
y = Data{:,1};
z = Data{:,6};
x = Data{:,7};
fill3(x,y,z,[1.00,0.00,0.00],'LineStyle','none','FaceAlpha',.3)
  2 件のコメント
Matt J
Matt J 2023 年 6 月 7 日
編集済み: Matt J 2023 年 6 月 7 日
We don't have your Data variable, so we cannot demonstrate solutions. I suggest attaching it in a .mat file.
C.PR
C.PR 2023 年 6 月 7 日
Thank you Matt,
Please find the attached Data File

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

採用された回答

Star Strider
Star Strider 2023 年 6 月 7 日
I am not certain what result you want with respect to ‘under the plotted curves’. Adjusting that limit (defined here as ‘min(Data{:,2+2*(k-1)})’) is relatively straightforward if you want to change it.
Try this —
LD = load('Data.mat');
Data = LD.Data
Data = 100×7 table
VarName1 VarName2 VarName3 VarName4 VarName5 VarName6 VarName7 ________ ________ ________ ________ ________ ________ ________ 1 67.231 1 73.18 2 112.26 3 2 69.409 1 71.076 2 112.61 3 3 68.738 1 69.451 2 113.52 3 4 70.1 1 69.531 2 109.96 3 5 71.74 1 71.117 2 109.97 3 6 71.016 1 71.371 2 108.34 3 7 71.03 1 70.978 2 107.89 3 8 71.213 1 73.032 2 104.09 3 9 71.743 1 72.724 2 104.54 3 10 73.342 1 72.288 2 103.65 3 11 74.851 1 73.168 2 106.35 3 12 75.568 1 71.517 2 108.51 3 13 77.95 1 72.744 2 103.95 3 14 78.961 1 74.973 2 101.72 3 15 78.48 1 75.622 2 99.964 3 16 76.903 1 74.491 2 102.6 3
c = 'bgr';
figure
x = Data{:,1};
hold on
for k = 1:3
% Q = [2+2*(k-1); 3+2*(k-1)]
% plot3(Data{:,3+2*(k-1)}, x, Data{:,2+2*(k-1)})
patch([Data{:,3+2*(k-1)}; flip(Data{:,3+2*(k-1)})], [x; flip(x)], [Data{:,2+2*(k-1)}; zeros(size(x))+min(Data{:,2+2*(k-1)})], c(k), 'FaceAlpha',0.5, 'EdgeColor','none')
end
hold off
grid on
view(-30,30)
.
  2 件のコメント
C.PR
C.PR 2023 年 6 月 7 日
Thank you very much.
Both answers helped, but showing me the script definitely made my day ! I couldn't find the right syntax for this part "[Data{:,2+2*(k-1)}; zeros(size(x))+min(Data{:,2+2*(k-1)})]"
Thank you very much for your help !
Star Strider
Star Strider 2023 年 6 月 7 日
As always, my pleasure!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2023 年 6 月 7 日
See the FAQ:
Basically you have to define a closed polygon.
  1 件のコメント
C.PR
C.PR 2023 年 6 月 7 日
Thank you very much.
It actually gave me the first part of the answer .. however using the patch function in 3D was not an easy task (for me) !

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by