필터 지우기
필터 지우기

Unusual arrangement of plot

조회 수: 12 (최근 30일)
Zeynab Mousavikhamene
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)

채택된 답변

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)

추가 답변 (1개)

Bjorn Gustavsson
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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by