MATLAB: Number coding the plot beside color coding

number codingplot

Hi all,
I am looking for a way to insert number coding of both the legend and the curves of the a graph with plot command. like attached figure ( I added numbers manually) do you know any way to do that. thanks for your time and help.number_coding plot.png

Best Answer

It is likely not possible to do exactly that, however you can come close.
Try this:
x = [1 10 14 17];
y = randi([-40 -11], 4, 6);
figure
plot(x, y, '.-')
text(ones(1, size(y,2)), y(1,:), compose('%d', 1:size(y,2)))
lgndc = compose('%d Curve %d', (1:size(y,2)).'*[1 1]);
legend(lgndc, 'Location','SW')
ylim([-45 max(ylim)])
You will need to produce your own version of ‘lgndc’. Just precede each entry by the number of the curve.