How do I use multiple markers for multiple lines in a single graph?
19 views (last 30 days)
Show older comments
Accepted Answer
Image Analyst
on 23 Oct 2022
Try this:
x = [0 : 300];
f = [0.015, 0.028, 0.054, 0.067, 0.080];
markerIndexes = 1 : 30 : length(x);
markerShapes = {'d', 'o', 's', '^', 'v'};
for k = 1 : length(f)
y = f(k) * x;
% Plot solid line in blue.
plot(x, y,'b-','LineWidth',1)
hold on
% Plot markers at subsampled points in red.
hp(k) = plot(x(markerIndexes), y(markerIndexes), 'linestyle', 'none', 'Color', 'r', 'Marker', markerShapes{k}, 'MarkerSize',5);
legendStrings{k} = sprintf('f = %.3f GHz', f(k));
end
grid on;
legend(hp, legendStrings, 'Location', 'northwest')
xlabel('x')
ylabel('y')
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
