how to plot the lower or upper boundary lines for scatter data?

조회 수: 16 (최근 30일)
roudan
roudan 2018년 1월 29일
댓글: roudan 2018년 1월 30일
Hi
I have a scatter plot. I'd like to plot the lines connecting the points either the upper or lower bound.
How to do it?
Could you please help? Thank you so much.

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 29일
You could use boundary() to help figure out which points are on the perimeter. Figuring out which of those points are on the upper or lower branch might take some thinking for irregular point distributions.
  댓글 수: 1
roudan
roudan 2018년 1월 30일
Thanks Walter. It indeed takes some time to figure out how to find the lower bounds points.
Here are my codes and it works for my case
% if trendline is for boundary line
if ~isempty(strfind(trendlinecoverage,'bound')) % find the lowerbound string
k=boundary(xdata_crossplot',ydata_crossplot'); % have to be column vector
boundarypoint=[];
startx=k(1);
maxindex=length(k);
boundarypoint=[boundarypoint startx];
for i=2:maxindex
currentpointindex=k(i);
previouspointindex=k(i-1);
if xdata_crossplot(currentpointindex)>xdata_crossplot(previouspointindex) % we are moving in x+ direction to find the lower boundary point
boundarypoint=[boundarypoint k(i)];
end
end
hold(hrightsubplot,'on');
legendlabel_boundary='lower boundary line'
hp=plot(hrightsubplot,xdata_crossplot(boundarypoint),ydata_crossplot(boundarypoint),'-b','linewidth',2,'DisplayName',legendlabel_boundary);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by