How to plot shaded areas with legend
조회 수: 13 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!