Figure line won't connect/display all data points

조회 수: 38 (최근 30일)
Gino Battistella
Gino Battistella 2021년 2월 24일
댓글: Star Strider 2021년 2월 24일
For some reason matlab won't plot all my data points. when i hover over the last part (18-19km) it says there should be data points but there is no line connecting them or even points showing them. I have tried changing the renderer from painter to zbuffer or opengl (like was recommended on this forum) but neither seems to work.
%% plot Q vs distance
figure
set(gcf,'renderer','zbuffer')
plot(midpoint,Q)
title('Mean Q after bootstrapping')
grid on
xticks(0:1.5:19.5) %proxy
xlim([0 19.5]) %proxy
xlabel('Midpoint distance [km]')
ylabel('Q')
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2021년 2월 24일
hello
there is no line plotted in this area because there are only single (valid) values between NaNs , so this cannot generate a continuous line plot; you need two contiguous non-Nan values to have a line segment
I changed your plot command to
plot(midpoint_overlap_seq_sort,Qv_seq_sort,'-*')
and now you will see all your data - zoom in the last part of the plot :
the "isolated" data will appear as a dot , the contiguous non-Nan values will appear as line segments
Gino Battistella
Gino Battistella 2021년 2월 24일
I didn't know about the effects of NaN values on plotting, so thanks a lot!

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

채택된 답변

Star Strider
Star Strider 2021년 2월 24일
Isolated points only plot if specified as markers.
Try this:
D1 = load('midpoint.mat');
midpoint = D1.midpoint_overlap_seq_sort;
D2 = load('Q.mat');
Q = D2.Qv_seq_sort;
Lv = ~isnan(Q); % Vector Of Non-‘NaN’ Values
disc_pts = strfind(Lv.', [0 1 0])+1; % Locations Of Isolated Non-‘NaN’ Values
figure
plot(midpoint, Q) % Continuous Data
hold on
plot(midpoint(disc_pts), Q(disc_pts), '.r') % Isolated Points
hold off
grid
legend('Continuous Data', 'Isolated Points', 'Location','NW')
producing:
.
  댓글 수: 3
Mathieu NOE
Mathieu NOE 2021년 2월 24일
yep - no problem if I lost one opportunity to win an answer ! Star Strider managed it better than me ...
i am not in a beauty contest here ....
Star Strider
Star Strider 2021년 2월 24일
Gino Battistella — As always, my pleasure!
Mathieu NOE — Thank you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by