Showing markers to plot legend
古いコメントを表示
Hiya! I got this code (below) and I want to add the markers to a legend, how would I go about this?
figure(4); clf
p = plot(faun.age, faun.depth, '-diamond', 'LineWidth', 1.2);
grid on
set(gca, 'YDir', 'reverse')
xlabel('Age (ka BP)')
ylabel('Depth (mm)')
title('Age-Depth Relationship with Nps data')
p.MarkerEdgeColor = [1 0.5 0];
回答 (2 件)
Star Strider
2026 年 11 月 10 日 22:15
1 投票
Add that and it should work.
There are two closely related ways to handle this.
faun.age = [5 7 4 9];
faun.depth = [2 3 4 3];
figure(1)
p = plot(faun.age, faun.depth, '-diamond', 'LineWidth', 1.2, 'displayname', 'depth');
grid on
set(gca, 'YDir', 'reverse')
xlabel('Age (ka BP)')
ylabel('Depth (mm)')
title('Age-Depth Relationship with Nps data')
p.MarkerEdgeColor = [1 0.5 0];
legend show
figure(2)
p = plot(faun.age, faun.depth, '-diamond', 'LineWidth', 1.2);
grid on
set(gca, 'YDir', 'reverse')
xlabel('Age (ka BP)')
ylabel('Depth (mm)')
title('Age-Depth Relationship with Nps data')
p.MarkerEdgeColor = [1 0.5 0];
legend('depth')
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

