Error in the chart legend
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/218475/image.png)
3 Kommentare
Adam Danz
am 7 Mai 2019
I'm assuming that the triple does produce the line specs shown in the first 4 legend elements.
Adam Danz
am 20 Mai 2019
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');
Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!