Legend has different color lines from plot lines
显示 更早的评论
I have the following code to plot some data but the line colors are different from legend's line colors. How I could corrrect it?
for allSS=1:size(scnames,1) ;
nameofsource2open = scnames{allSS,1};
allTCON =[0.3;0.5]
allTECO =[0.2;0.77]
allTENV = [0.56; 0.888]
XallSS2plot = [allTCON(allSS)*0; allTECO(allSS)*(sqrt(3))/2; allTENV(allSS)*(-((sqrt(3))/2));allTCON(allSS)*0]
YallSS2plot = [allTCON(allSS)*1; allTECO(allSS)*(-0.5); allTENV(allSS)*(-0.5);allTCON(allSS)*1]
Xindex2plot = XallSS2plot(:)
Yindex2plot = YallSS2plot(:)
axis , hold on
for i=1:size(scnames,1)
col = rand(i,3)
nameofsource2open = scnames{allSS,1};
hh(i) = plot(XallSS2plot(:,1),YallSS2plot(:,1), 'Color', col(i,:),'LineWidth',2)
legendtext{i} = scnames;
hhh = legend(hh, 'DisplayName',legendtext{i})
linecolors{i} = col(i,:)
legendlinestyles(hhh, {},{},linecolors{i})
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!