How to fill the area under the curve ?
41 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 7 Jun 2023
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
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 Comments
More Answers (1)
See Also
Categories
Find more on Line Plots 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!