Legend - set legend to 2 group of data

11 views (last 30 days)
Jonasz
Jonasz on 22 Dec 2013
Answered: dpb on 22 Dec 2013
Hello I have two data (52,60 lines on plot) I want to have a legend like this
LINES 1 - colour blue
LINES 2 - colour red
But all the time I get the same blue colour because my legend count lines not the group of data . How to set it or skip values ?
I tried to do this like this :
ik=[X(M,N-1),X(M,N),X(M,N+1)];
h1=plot(ik,DataX,'-b');
hold on;
h2=plot(ik,DataY,'-r');
legend([h1 h2],{'ROI2','ROI3'}
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
M,N are single numbers eg. 100 (index)

Answers (1)

dpb
dpb on 22 Dec 2013
Apparently Data[X|Y] have differing number of columns so since plot returns a column vector of line handles then [h1 h2] is trying to place to columns of different lengths side-by-side.
Use
[h1; h2]
or
[h1' h2']
instead.

Products

Community Treasure Hunt

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

Start Hunting!