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

28 次查看(过去 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