How can I add a horizontal dashed line with a text description above it to a specific coordinate?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Navid
el 14 de Nov. de 2023
Comentada: Star Strider
el 15 de Nov. de 2023
Dear all, I would like to inquire about the process of adding a horizontal dashed line with a text description above it to a specific coordinate on a graph, as demonstrated in Figure 1. I would appreciate it if you could guide me on how to do this. Thank you for your time and consideration.
Figure 1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1539782/image.png)
0 comentarios
Respuesta aceptada
Star Strider
el 15 de Nov. de 2023
Perhaps this —
t = linspace(0, 5);
k = 0.75;
y = 5*(1-exp(-k*t));
yval = 3;
tval = interp1(y, t, yval);
figure
plot(t, y)
hold on
plot([min(xlim) tval], [1 1]*yval, '--r', 'LineWidth',2)
plot(tval, yval, 'or', 'MarkerFaceColor','g', 'MarkerSize',8)
hold off
text(tval/2, yval, 'text', 'Horiz','center', 'Vert','bottom')
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations 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!