# How to label the curve instead of using legend?

146 visualizaciones (últimos 30 días)
Milind Amga el 19 de Jun. de 2022
Comentada: Milind Amga el 19 de Jun. de 2022
I wrote a code to plot a lot of graphs but while visualizing it becomes difficult to accertain which curve I am looking at, as some curves seems to have similar color. Is there any way I can add a name to the curve which is displayed the on the curve ( not like legend, it would appear near the individual curve) ?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Hiro Yoshino el 19 de Jun. de 2022
x = -pi:0.01:pi;
y1 = cos(x);
y2 = sin(x);
plot(x,y1,'b-'); hold on
plot(x,y2,'r-'); hold off
text(x(end),y1(end),"cos(x)",'Color','blue');
text(x(end),y2(end),"sin(x)",'Color','red');
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Milind Amga el 19 de Jun. de 2022
Thankyou, this approach seems just fine.

Iniciar sesión para comentar.

### Más respuestas (1)

Abhishek Tiwari el 19 de Jun. de 2022
Editada: Abhishek Tiwari el 19 de Jun. de 2022
Hi,
You can label your curve using text. Choose one of the point on each curve and add text in there to serve as a label.
Example:
openExample('graphics/LabelPointOnGraphExample') % use MATLAB Online
These might be useful:
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Milind Amga el 19 de Jun. de 2022
Thanks. I got the idea.

Iniciar sesión para comentar.

### Categorías

Más información sobre Legend en Help Center y File Exchange.

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by