Filling between several curves in a figure using fill or patch functions

4 ビュー (過去 30 日間)
hamed
hamed 2020 年 9 月 16 日
コメント済み: Ameer Hamza 2020 年 9 月 22 日
Hi
I have a figure, in which 4 curves are plotted. I want to fill between these curves twp by two with a specific color (red, green, ...) I attached the plots I want to fill. How can I do that?
Thanks

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 9 月 16 日
See this example
y = 1:400;
x1 = 0.1*rand(size(y));
x2 = 0.1*rand(size(y))+1;
x3 = 0.1*rand(size(y))+0.4;
x4 = 0.1*rand(size(y))+1.4;
ax = axes();
hold(ax);
plot(x1, y);
plot(x2, y);
Y = [y fliplr(y)];
X = [x1 fliplr(x2)];
p = patch(X, Y, 'r', 'FaceAlpha', 0.2);
Y = [y fliplr(y)];
X = [x3 fliplr(x4)];
p = patch(X, Y, 'g', 'FaceAlpha', 0.2);
  5 件のコメント
hamed
hamed 2020 年 9 月 21 日
編集済み: hamed 2020 年 9 月 21 日
Hi again Ameer,
I plotted a 1D signal in Matlab, and then I want to show the value of each specific sample by a district colour. something like what "imagesc" command does for 2D plots. I attached an example of what is in my mind. Any suggestions, please?
This is what I have written, but the distribution of the values is weird! I expected a linear behaviour of the values at each sample.
p(1, 2).select();
twt = tie_out_mid.well_log.logs.twt(97:end);
y = twt';
CGR = tie_out_mid.well_log.logs.cgr(97:end);
x = CGR';
x0 = zeros(size(x))';
Y1 = [y fliplr(y)];
X1 = [x0 fliplr(x)];
ColorData = vertcat (x', flip(x'));
patch(X1, Y1, ColorData);
Ameer Hamza
Ameer Hamza 2020 年 9 月 22 日
Can you show the expected output?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by