Filter löschen
Filter löschen

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

63 Ansichten (letzte 30 Tage)
Rahim Rahim
Rahim Rahim am 22 Jul. 2022
Kommentiert: Star Strider am 22 Jul. 2022
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

Antworten (1)

Star Strider
Star Strider am 22 Jul. 2022
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 Kommentare
Rahim Rahim
Rahim Rahim am 22 Jul. 2022
Thank you for your help but I want to appear the value on Y-axis
Star Strider
Star Strider am 22 Jul. 2022
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.
.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by