Hello,
I have complex data which I want to plot. My code is:
if true % code
endfor bb = 1:size(Data.Measured,2) %calculating how many measurements we have for right and left ear
idx1 = strfind(Data.Side, 'Right'); idx1 = find(not(cellfun('isempty',idx1))); N (bb) = length(idx1); idx2 = strfind(Data.Side, 'Left'); idx2 = find(not(cellfun('isempty',idx2))) ; M (bb) = length(idx2) ; for kk = 1:size(Data.Name,2) if strcmpi(Data.Side{kk}, 'Right') subplot(2,1,1) Data.legend.sub1{c1} = regexprep(Data.Name{kk},'_',' '); c1 = c1+1; legend(Data.legend.sub1(1:N)) title([name(bb),' Right']) else subplot(2,1,2) title([name(bb),' Left']) Data.legend.sub2{c2} = regexprep(Data.Name{kk},'_',' '); c2 = c2+1; legend(Data.legend.sub2(N+1:N+M)) end end
the problem I have here is that my Data.legend.sub1 and Data.legend.sub2 give me all measurements done for all subjects but in reverse order:
Data.legend.sub1
Data.legend.sub2
Thus, my legend is using different colours for different measurements. First, I want to make sure that I am only plotting measurements for right side (is it already ensured by line :if strcmpi(Data.Side{kk}, 'Right')?). second I want to use the same colours for the same measurement for both sides. third, I am not sure why I am getting warning 'Ignoring extra legend entries.' and then one measurement is always omitted in the legend and specified just as 'data 1'…
I hope my explanation is clear.
Best Answer