Borrar filtros
Borrar filtros

Label a plot

3 visualizaciones (últimos 30 días)
Ean Soo
Ean Soo el 9 de Mzo. de 2011
Hie all, i want to ask if i have plot a few graphs and the one below is the vertical line.Can i know how to label the vertical line like if the vertical like is z=100, i would like to label it as z=100.
y=get(gca,'ylim');
h=plot([z z],y,'-r');
Thank You Regards, Ean

Respuesta aceptada

Matt Fig
Matt Fig el 9 de Mzo. de 2011
Use the TEXT function. To see the help, use:
help text
In your case:
z = 100;
y=get(gca,'ylim');
h=plot([z z],y,'-r');
text(z,mean(y),'z = 100') % If text is too close to line, use z+inc.
  2 comentarios
Ean Soo
Ean Soo el 9 de Mzo. de 2011
Thanks Matt. Can i know how to use the z+inc?
Matt Fig
Matt Fig el 9 de Mzo. de 2011
inc is just an increment to add to the z. So if your xlim is [99 101], then and increment could be .1. If your xlim is is [0 1000], perhaps a larger increment would work - perhaps 1 or 2. I might even try to make the increment a function of xlim, say diff(xlim)/20 or whatever.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by