Legend - set legend to 2 group of data

9 次查看(过去 30 天)
Jonasz
Jonasz 2013-12-22
回答: dpb 2013-12-22
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)

回答(1 个)

dpb
dpb 2013-12-22
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.

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by