How to add a value of a point on y axis in a PLOT ?

조회 수: 102 (최근 30일)
Rahim Rahim
Rahim Rahim 2022년 7월 22일
댓글: Star Strider 2022년 7월 22일
For example many points and I want to display them in a Plot.
I want to appear the value of point on y axis, for example:
the point ( 4, 2.5), I want to display the 2.5 on the Y axis and a small line between the point and its Y value

답변 (1개)

Star Strider
Star Strider 2022년 7월 22일
Possibly —
point = [4, 2.5];
figure
plot(point(1), point(2), 'or', 'MarkerFaceColor','r')
axis([0 5 0 5])
hold on
plot([1 1]*point(1), [min(ylim) point(2)], ':r') % Vertical Line
plot([min(xlim) point(1)],[1 1]*point(2), ':r') % Horizontal Line
hold off
grid
text(point(1), point(2), sprintf('(%.1f,%.1f)',point), 'Horiz','left', 'Vert','bottom')
.
  댓글 수: 2
Rahim Rahim
Rahim Rahim 2022년 7월 22일
Thank you for your help but I want to appear the value on Y-axis
Star Strider
Star Strider 2022년 7월 22일
point = [4, 2.5];
figure
plot(point(1), point(2), 'or', 'MarkerFaceColor','r')
axis([0 5 0 5])
hold on
plot([1 1]*point(1), [min(ylim) point(2)], ':r') % Vertical Line
plot([min(xlim) point(1)],[1 1]*point(2), ':r') % Horizontal Line
hold off
grid
text(point(1), point(2), sprintf('(%.1f,%.1f)',point), 'Horiz','left', 'Vert','bottom')
text(-0.08, 2.5, '2.5', 'Color','r', 'Horiz','right')
The only option appeaars to be to manually overwrite it. The properties that I can find do not allow changing properties for a specific tick label, such as color or anything else.
.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by