フィルターのクリア

How to plot shaded areas with legend

6 ビュー (過去 30 日間)
Sarfaraz Ahmed
Sarfaraz Ahmed 2021 年 7 月 11 日
編集済み: Sarfaraz Ahmed 2021 年 7 月 12 日
Hello MATLAB Community,
I am trying to shade PSD spectrum for specific region for example :
f(ind1:ind2) -> nothing
f(ind3:ind4) -> light shaded area
f(ind5:end) -> dark shaded area
The capture_ref.png is attached for referance. I want same thing on (capture.png) which is generate from MATLAB Script.
Also, There must be legent for both shaded areas.
can any one please help in this regard ?
Thank you in advance.

採用された回答

KSSV
KSSV 2021 年 7 月 11 日
Example;
clc; clear all
x = 1:10 ;
y = rand(size(x)) ;
figure
hold on
% Region1
area([x(1:4) x(1)],[y(1:4) y(1)])
area([x(4:7) x(4)],[y(4:7) y(4)])
area([x(7:10) x(7)],[y(7:10) y(7)])
Instead of area you can also use patch, fill.
  1 件のコメント
Sarfaraz Ahmed
Sarfaraz Ahmed 2021 年 7 月 12 日
編集済み: Sarfaraz Ahmed 2021 年 7 月 12 日
Hi, Thank you for your answer.
I tried something like this, but it's not as its expected .
figure(3)
[pxx,f] = pwelch(rwave_decimate_1,[],[],[],fs/N);
pxx_n =pxx/max(pxx);
hold on;
area(f(1:13),pxx_n(1:13));
area(f(13:52),pxx_n(13:52),'basevalue',0,'FaceColor','g');
area(f(52:end),pxx_n(52:end),'basevalue',0,'FaceColor','k');
hold off
legend('VLF','LF','HF')
However, the result is on attached capture.png. what I want is :
a) initial area should not be highlighted and also no legend for 1st area.
b) 2nd and 3rd area should have legend and color should be light shaded and dark shaded as in the capture_ref.png.
I look forward for such answer.
Thank you.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by