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

105 次查看(过去 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

回答(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