필터 지우기
필터 지우기

Include "star dot" in plot legend.

조회 수: 5 (최근 30일)
matlabkid602
matlabkid602 2018년 2월 4일
댓글: Star Strider 2018년 2월 4일
I'm plotting three sets of data with the code
if true
plot(x_1,y_1,x_2,y_2,x_3,y_3) %Layered plot
xlabel('X')
ylabel('Y')
title('Particle Trajectory')
legend('Particle 1','Particle 2','Particle 3')
end
The data set x_1,x_2 is just the origin 0,0 in every component.
How can I include a solid dot at the centre of the plot and include this in the legend?

채택된 답변

Star Strider
Star Strider 2018년 2월 4일
I am not certain what you want to do.
Try this:
x = [-1 1 -1 1];
y = [-1 1 1 -1];
x1 = 0;
y1 = 0;
figure(1)
L1 = plot(x1, y1, 'pg', 'MarkerSize',10, 'MarkerFaceColor','g');
hold on
L2 = plot( x, y, 'ob', 'MarkerSize',10, 'MarkerFaceColor','b');
hold off
legend(L1, 'Centre')
Ax = gca;
Ax.XAxisLocation = 'origin';
Ax.YAxisLocation = 'origin';
axis([-1.5 1.5 -1.5 1.5])
grid on
Experiment to get the result you want.
  댓글 수: 3
matlabkid602
matlabkid602 2018년 2월 4일
The dot should be at (0,0)
Star Strider
Star Strider 2018년 2월 4일
In my example code, the (x1,y1) dot is at the centre, at (0,0), and has its own legend entry.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by