Check out example codes for "matlab plot legend". It will help you in understanding the concepts better.

Code Example 1

x = linspace(0,pi);
y1 = cos(x);
plot(x,y1)

hold on 
y2 = cos(2*x);
plot(x,y2)

legend('cos(x)','cos(2x)')

Learn ReactJs, React Native from akashmittal.com