MATLAB: Unusual arrangement of plot

plotplotting

Red line is plotted by matlab but it is unusal and expected to be blue line.
Any idea why this happens?
plot(celltracker_group_prolif.radius(celltracker_group_prolif.time==22),celltracker_group_prolif.perhex(celltracker_group_prolif.time==22),'-rs','LineWidth',2,…
'MarkerEdgeColor','k',…
'MarkerFaceColor','g',…
'MarkerSize',5)

Best Answer

I assume when you say "Red line is plotted by matlab but it is unusal and expected to be blue line" you mean that you expect the red line to be close to the blue line.
It looks like your data is probably not sorted in order of increasing x value.
You can use the sort command to sort your data. So if your values were in a vector y, and your x values were in a vector x you could sort them according to their x values using
[xsort,isrt] = sort(x)
ysort = y(isrt)