MATLAB Answers

Figure line won't connect/display all data points

27 views (last 30 days)
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 Comments
Gino Battistella
Gino Battistella on 24 Feb 2021
I didn't know about the effects of NaN values on plotting, so thanks a lot!

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 24 Feb 2021
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 Comments
Star Strider
Star Strider on 24 Feb 2021
Gino Battistella — As always, my pleasure!
Mathieu NOE — Thank you.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!