MATLAB: Plot, legend, settings, appearance

legendplot

Hi, I have following question: This question is about a plot as in the image bellow.
clear all;
close all;
x=(1:1:50);
y=x.^2;
plot(x,y,'-b');
hold on;
plot(x(1:5:end),y(1:5:end),'bo');
legend('data','Location', 'northeast');
Because the points are very close each other and I have multiple graphs I have to use markers. The problem is that I would like to have a legend showing not (data and data 2) but let say (data) which it combines both the marker and the line. Can be somehow overwritten the actual legend or create other new? Thank you
<<
>>

Best Answer

If I understand correctly what you want to do, change this plot call:
plot(x, y,'-b');
hold on;
plot(x(1:5:end),y(1:5:end),'bo');
to simply:
plot(x, y, '-ob')
—————————————————————————————————————
EDIT: Changed to reflect ‘x’ and ‘y’ now appearing on both plot calls in the original Question.