필터 지우기
필터 지우기

Shade area between two curves and maintain central solid line in shaded area

조회 수: 1 (최근 30일)
Hi MATLAB community
I am knew to programing in MATLAB and using it to assist in streamlining some graphing process's with data (I am a biomechanics)
I have written a script to plot outputs from the program I use (which initially exports to excel) and have placed it below. I am wondering how to go about writing script to shade the area between y1sdupper and y1sdlower in a transparent red, as well as shade the area between y2sdupper and y2sdlower with a transparent blue (these are the +/- 1sd of the mean) while still keeping the solid y1 and y2 line visible. Any assistance will be greatly appreciated.
fprintf('Please note: Excel file setup:\n')
fprintf('Column A = x1\n')
fprintf('Column B = y1\n')
fprintf('Column C = y1SD\n')
fprintf('Column D = y2\n')
fprintf('Column e = y2SD\n')
fprintf('please ensure the excel file is saved in your "Current Folder"\n\n')
fprintf('If you have already completed this, please wait the program will sart in 5 seconds:\n\n')
pause(5)
fprintf('BLASTOFF')
pause (1)
prompt = {'Enter file name:'};
dlg_title = 'Input';
num_lines = 1;
defaultans = {'Book1'};
a = inputdlg(prompt,dlg_title,num_lines,defaultans);
file = strjoin(a);
data = xlsread(file);
x1 = data(:,1);
y1 = data(:,2);
y1sdupper = data(:,2) + data (:,3);
y1sdlower = data(:,2) - data (:,3);
y2 = data(:,4);
y2sdupper = data(:,4) + data (:,5);
y2sdlower = data(:,4) - data (:,5);
plot(x1, y1, 'r', x1, y2, 'b', x1, y1sdupper, 'r--', x1, y1sdlower, 'r--', x1, y2sdupper, 'b--', x1, y2sdlower, 'b--')
Cheers Matt
  댓글 수: 1
Star Strider
Star Strider 2017년 5월 7일
The patch function will shade the area you want.
I cannot run your code, and I have no idea what you actually want to do.

댓글을 달려면 로그인하십시오.

채택된 답변

Chad Greene
Chad Greene 2017년 9월 6일
Hi Matt,
I recommend Kelly Kearney's boundedline function. Just give it the central line and error values, and it figures out the rest. Like everything I've seen by Kelly, it's well designed and well documented.

추가 답변 (1개)

Maitreyee Mordekar
Maitreyee Mordekar 2017년 5월 16일
Hey,
Maybe the following links will help you implement your requirement:
  • https://in.mathworks.com/matlabcentral/answers/180829-shade-area-between-graphs
  • https://in.mathworks.com/matlabcentral/fileexchange/13188-shade-area-between-two-curves
  • https://in.mathworks.com/matlabcentral/answers/14005-how-can-i-shade-the-area-between-two-curve
Hope that helps!

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by