Hi there,
I'm trying to add a legend for my figure but the legend dose not match the matrix colour.
this is my code
figure
plot(Leftdata ,'K');hold on ;plot(Rightdata,'r'); % the size of Leftdata and the right data are 10coulumns and 101 rows for each.
grid on
grid minor
legend('Left','Right');
Any Suggestion to figure this problem out!!!!
Your help is greatly appreciated :)
Thanks

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 3일
편집: KALYAN ACHARJYA 2019년 6월 4일

2 개 추천

Its not a single lines, its bunch of lines
#Edited
p1=plot(Leftdata,'K');
hold on ;
p2=plot(Rightdata,'r');
grid on
grid minor
legend([p1(1),p2(2)],'left data','right data')

댓글 수: 3

Amneh Alshawabka
Amneh Alshawabka 2019년 6월 3일
Thank you for your help. I have tried this before but still not working and give me these errors
Error in legend (line 162)
all(isgraphics(args{1})) % legend(children,strings,...)
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Any suggestions?
Thanks alot
Amneh Alshawabka
Amneh Alshawabka 2019년 6월 3일
I have tried your first reply, this one
legend([p1(1),p2(2)],'left data','right data'), It's worked very well :)
Thank you so much :)
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 4일
Welcome @Amneh

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by