MATLAB: How to generate and use different colours on a plot and label as per the colours

plot

Hello all
I want to know how i can generate different colours and use those in my figure and then place on the figure that what colours represents what. My figure will look like the attached image, its only a 3 case example but my final image consits of large number of cases which are variable. In example image I want to add futher the labelling scheme performing like legend,showing colour=abc(pharase) etc.
I hope to get an answer soon
Regards

Best Answer

plot(rand(10,4)) % plot 4 lines in default color cycle
legend('a', 'b', 'c', 'd') % label them -- colors show automagically
text(2,0.05,'Stuff in green','color','g') % add some text in a color
You can create custom colors or select the named colors from a list--there are many examples in the doc. See the doc on the various functions above and the links on annotation and enhancement in the Graphics section.