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.

採用された回答

Voss
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]);
  1 件のコメント
Ali alshamrani
Ali alshamrani 2022 年 5 月 6 日
Thank you so much. However, how did you come up with these number for h_idx = [ ...
6 9;

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by