Shade or fill area between several lines in same plot (probability function was used for plotting)
1 次查看(过去 30 天)
显示 更早的评论
I am trying to shade or fill area between lines in same plot. Plot and data is attatched.
0 个评论
采纳的回答
Voss
2022-5-6
One way is to use patch
load('Florea_2.mat');
% annularrimx = xlsread('C:\Users\almha\Desktop\Rayan\Probability.xlsx'); % I changed this, if different location, you can change it back
%
%
% x = annularrimx(:,1);
figure
% hold all
% store the handles to the plotted lines in variable h
h = probplot('lognormal',[sample_02.Discharge_ratio sample_04.Discharge_ratio sample_07.Discharge_ratio sample_08.Discharge_ratio sample_10.Discharge_ratio sample_13.Discharge_ratio sample_21.Discharge_ratio sample_22.Discharge_ratio sample_23.Discharge_ratio],'noref');
% area(x,sample_04, 'g')
grid on
% hold off
legend(sample_02.info,sample_04.info,sample_07.info,sample_08.info,sample_10.info,sample_13.info,sample_21.info,sample_22.info,sample_23.info)
title('{\bf Probability Plot}')
set(get(gca,'XLabel'),'String','Discharge Ratio (Q/Qmin)')
% indices of plotted lines to fill between (adjust as needed):
h_idx = [ ...
6 9; ... % fill between Royal, KY, line and Comal, TX, line, using color of Royal, KY, line
9 8; ... % fill between Comal, TX, line and Blue, MO, line, using color of Comal, TX, line
8 7; ... % etc.
7 3; ...
3 2; ...
2 5; ...
5 1; ...
1 4; ...
];
p = zeros(size(h_idx,1),1);
for ii = 1:size(h_idx,1)
p(ii) = patch( ...
[h(h_idx(ii,1)).XData h(h_idx(ii,2)).XData(end:-1:1)], ...
[h(h_idx(ii,1)).YData h(h_idx(ii,2)).YData(end:-1:1)], ...
h(h_idx(ii,1)).Color);
end
set(p,'EdgeColor','none','HandleVisibility','off','FaceAlpha',0.5);
set(gca(),'Children',[h(end:-1:1); p]);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!