Error in the chart legend
古いコメントを表示
Hello
Why do I have a bug in the legend?
Code:
for i=1:1:4
w1=subplot(1,2,1);hold on;
p(i)=plot( w1,TR,y,[znaki(i),rodzaj{i},kolor(i)]);
legend(w1,'w1 ','w2 ','w3','w4');
end

3 件のコメント
Walter Roberson
2019 年 5 月 7 日
That would be an error unless znaki is a character vector and rodzaj is a cell array of character vectors, and kolor is a character vector, such that the triple [znaki(i), rodzaj{i},kolor(i)] forms a linespec . Which is plausible looking at your graph.
Adam Danz
2019 年 5 月 7 日
I'm assuming that the triple does produce the line specs shown in the first 4 legend elements.
Adam Danz
2019 年 5 月 20 日
It looks like additional plotting is done elsewhere in your code. Try this if you only want the first 4 objects in your legend.
w1=subplot(1,2,1);hold on;
for i=1:1:4
p(i)=plot( w1,TR,y,[znaki(i),rodzaj{i},kolor(i)]),'DisplayName', sprintf('w%d',i);
end
legend(p,'AutoUpdate ', 'off');
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!