Hello, I would like to show the legend for a1 and (a3,a4) together.
But when I run it both legend entry are displayed with a black filled dot and not with the red one (the second).
How can I fix it?
figure(1)
for i = z
hold on; grid on; grid minor; axis equal;
set(gcf, 'Color', 'White');
set(gca, 'Fontsize', 12);
set(gca, 'ZDir','reverse')
a1 = scatter3(x*100,y*100,i*100,15,'filled', 'k');
a2 = plot3(X3D*100, Y3D*100, Z3D*100, 'k');
a3 = scatter3(C2(:,1),C2(:,2),C2(:,3),'filled', 'r'); %No Flow
a4 = scatter3(C22(:,1),C22(:,2),C22(:,3),'filled', 'r'); %No Flow
view(3)
xlabel('x [mm]')
ylabel('y [mm]')
zlabel('z [mm]')
legend([a1, a3 a4], 'Fiducial Markers', 'IPR Markers')
title('Fiducial Markers vs. IPR Tracked Markers')
subtitle('Wing NO Flow - 6DOF Fit')
end

 채택된 답변

Star Strider
Star Strider 2022년 7월 1일

1 개 추천

I am not able to run the code so I cannot test this, however one approach could be:
legend([a1(1), a3(1) a4(1)], 'Fiducial Markers', 'IPR Markers')
Experiment with that approach (or similar approaches).
(I will delete my Answer if it fails to solve the problem.)
.

댓글 수: 4

Fabio Taccaliti
Fabio Taccaliti 2022년 7월 1일
Hi, thanks a lot! It is working now :)
Why I should add (1) to the datasets?
Star Strider
Star Strider 2022년 7월 1일
As always, my pleasure!
Your code plots vectors of points, and the legend function will obediently assign consecutive points to each consecutive legend string entry. The (1) subscript tells legend to only use the first element in each vector to assign to a legend string entry.
.
Fabio Taccaliti
Fabio Taccaliti 2022년 7월 1일
Ahh, clear!! Thanks a lot.
Star Strider
Star Strider 2022년 7월 1일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

태그

질문:

2022년 7월 1일

댓글:

2022년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by