How to add a value of a point on y axis in a PLOT ?
조회 수: 102 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!