How to add a value of a point on y axis in a PLOT ?
102 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 22 de Jul. de 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 comentarios
Star Strider
el 22 de Jul. de 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.
.
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!