Connect points to the straight line
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everybody,
How can I connect the points to the straight line in the figure ?
Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/352466/image.jpeg)
2 comentarios
Respuestas (1)
Star Strider
el 27 de Ag. de 2020
Editada: Star Strider
el 27 de Ag. de 2020
Try this (with your own data):
x = 1:10; % Create Data
y = 2.5*rand(size(x)); % Create Data
stln = 0;
figure
plot(x, stln+zeros(size(x)), '-r') % Straight Line
hold on
plot(x, y, 'xk') % Points
plot([x; x], [zeros(size(y))+stln; y], '-g') % Connecting Lines
hold off
ptlbls = compose(' %2.1f', y);
text(x, y, ptlbls, 'HorizontalAlignment','left', 'VerticalAlignment','middle')
axis([0 11 -0.1 2.5])
Make appropriate changes to use it with your data.
4 comentarios
Star Strider
el 28 de Ag. de 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!