MATLAB Answers

0

Unusual arrangement of plot

Zeynab Mousavikhamene さんによって質問されました 2019 年 10 月 7 日
最新アクティビティ Bjorn Gustavsson さんによって 回答されました 2019 年 10 月 7 日
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)

  0 件のコメント

サインイン to comment.

タグ

2 件の回答

Jon
回答者: Jon
2019 年 10 月 7 日
編集済み: Jon
2019 年 10 月 7 日
 採用された回答

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)

  0 件のコメント

サインイン to comment.


回答者: Bjorn Gustavsson 2019 年 10 月 7 日

Seems like you want the plot done with the radii sorted? (plot plots what you feed it, if you have the x-variable unsorted the plot will be with the x-array as given...). Maybe something like:
x4p = celltracker_group_prolif.radius(celltracker_group_prolif.time==22);
y4p = celltracker_group_prolif.perhex(celltracker_group_prolif.time==22);
% Check the order of x4p!
[~,is] = sort(x4p);
plot(x4p(is),y4p(is),'-rs','linewidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
HTH

  0 件のコメント

サインイン to comment.



Translated by