Fill area between two vertical curves

9 ビュー (過去 30 日間)
Marcus Johnson
Marcus Johnson 2024 年 3 月 25 日
コメント済み: Marcus Johnson 2024 年 3 月 25 日
Hello,
I have the following code:
value = [NaN NaN NaN 186.7646 198.4115 191.1406 180.8430 175.7136 ...
167.7459 151.2865 144.5964 139.8148 139.4305 188.2865 204.3296 228.8586 254.0547]; % My values
std = [NaN NaN NaN 78.2946 81.7295 83.1143 84.2082 84.5829 82.0337 83.9719 83.5152 81.8107 94.7622 ...
91.5085 81.8504 82.4451 91.2520]; % The standard deviation of the values
height = [500 1000 1500 2000 3000 4000 5000 6000 7000 ...
8000 9000 10000 11000 12000 13000 14000 15000]; % The altitudes
figure
hold on
plot(value,height,'r')
plot(value-std,height,'black')
plot(value+std,height,'black')
ylim([0 15000])
yticks([500 1000 1500 2000 2500 5000 7500 10000 12500 15000])
xlim([0 360])
xticks([0 90 180 270 360])
Is there a way to shade the area between the two black curves?
Sort of like the way it is done in these figures:
  2 件のコメント
Alexander
Alexander 2024 年 3 月 25 日
Only some piece of advice, it's not a good idea to use std as variable because it's shadowing the function std().
Marcus Johnson
Marcus Johnson 2024 年 3 月 25 日
That is true, I just used the name std here to indicate that it is the standard deviation. In my actual code I have a different name.

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

採用された回答

Alan Stevens
Alan Stevens 2024 年 3 月 25 日
Like this:
value = [186.7646 198.4115 191.1406 180.8430 175.7136 ...
167.7459 151.2865 144.5964 139.8148 139.4305 188.2865 204.3296 228.8586 254.0547]; % My values
std = [78.2946 81.7295 83.1143 84.2082 84.5829 82.0337 83.9719 83.5152 81.8107 94.7622 ...
91.5085 81.8504 82.4451 91.2520]; % The standard deviation of the values
height = [2000 3000 4000 5000 6000 7000 ...
8000 9000 10000 11000 12000 13000 14000 15000]; % The altitudes
figure
hold on
X = [value-std, fliplr(value+std)];
Y = [height, fliplr(height)];
fill(X,Y,'g')
plot(value,height,'r')
plot(value-std,height,'black')
plot(value+std,height,'black')
ylim([0 15000])
yticks([500 1000 1500 2000 2500 5000 7500 10000 12500 15000])
xlim([0 360])
xticks([0 90 180 270 360])
  1 件のコメント
Marcus Johnson
Marcus Johnson 2024 年 3 月 25 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by