Create a filling between cftool prediction bounds

조회 수: 2 (최근 30일)
Yoav Romach
Yoav Romach 2014년 3월 20일
답변: Yoav Romach 2014년 3월 26일
Hey there,
Not sure if it's even possible in Matlab, but since it's possible in other programs I'll ask :)
I have some data that I've fitted, and I've generated the code and I'm using this code to plot it:
fitresult = fit( xData, yData, ft, opts );
xFit = logspace(4,8,1000);
yFit = fitresult(xFit);
yPredict = predint(fitresult,xFit,0.683,'functional','off');
% Plot fit with data.
hold on
h = loglog(sample69_nv20_binw,sample69_nv20_bins,'rd',sample69_nv20_binw,sample69_nv20_bins,'r.',xFit,yFit,'r',xFit,yPredict,'r--');
This works well, but I would like to make the prediction area filled in light, transparent red color instead of marking the borders, similar to what you can see in the attached picture.
Is it possible? how so?

채택된 답변

Yoav Romach
Yoav Romach 2014년 3월 26일
So I've found the quick way to do it and I'll add it for reference, but it's simplify calling "area" with the x and y data, much easier than patch or other methods:
fitresult = fit( xData, yData, ft, opts );
xFit = logspace(4,8,1000);
yFit = fitresult(xFit);
yPredict = predint(fitresult,xFit,0.683,'functional','off');
% Plot fit with data.
hold on
h = loglog(sample69_nv20_binw,sample69_nv20_bins,'rd',sample69_nv20_binw,sample69_nv20_bins,'r.',xFit,yFit,'r');
area(xFit,yPredict,'EdgeColor','none','FaceColor',[1 0.3 0.3]);
alpha(0.1);

추가 답변 (1개)

Dishant Arora
Dishant Arora 2014년 3월 20일
You haven't attached anything, as per my guess *fill* will do the job. See this:
X = rand(1,100);
Y = rand(1,100)+1;
fill([1:100 , fliplr(1:100)] , [X , fliplr(Y)] , 'r')
  댓글 수: 3
Dishant Arora
Dishant Arora 2014년 3월 20일
Transparency is only observed by image, surface, and, patch objects. So, use patch instead of fill. It's arguments are vertices of the polygon you want to fill.
Yoav Romach
Yoav Romach 2014년 3월 21일
Hey, Thanks.
So I've managed to create the correct polygon using
patch([xFit;xFit],[yPredict(:,1)';yPredict(:,2)'],?)
But I'm having problem with getting the color right, it seems that no matter what I put instead of the ? it comes out black :(
I was also unable to get it transparent.
Can you help?
Thanks!

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

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by