Hi, Can someone tell me how to remove (data1 that caused by the reference line) from legend?
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ORION OMN
am 3 Apr. 2019
Kommentiert: Adam Danz
am 18 Jan. 2021
set(gca,'YTICK',[0 13.6 20 40]);
plot(x ,SNR_db,'Color',color,'LineStyle',style );
lgd = legend( 'theta 30,FOV 50','theta 40,FOV 20','theta 40,FOV 30','with less error','ideal case');
end
hold off
hline = refline(0,13.6);
set(hline,'color','k');
%set(hline,'Marker','o');
set(hline,'LineStyle','-');
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 3 Apr. 2019
Bearbeitet: Adam Danz
am 3 Apr. 2019
Option 1
Turn off auto-updating so objects plotted after calling legend() do not appear on the legend.
lgd = legend( 'theta 30,FOV 50','theta 40,FOV 20','theta 40,FOV 30','with less error','ideal case', ...
'AutoUpdate','off');
Option 2
Plot the legend at the end and specify the object handles that should appear in the legend.
h = plot(x,y);
lgd = legend(h, 'theta 30,FOV 50');
% h can be a vector corresponding to each label name.
If you use the DisplayName property, you just need to provide the handles.
h = plot(x,y,'DisplayName', 'theta 30,FOV 50');
lgd = legend(h);
1 Kommentar
Weitere Antworten (1)
Muhammad Qasim
am 18 Jan. 2021
Hi,
write this before reference line code.
legend('AutoUpdate','off')
1 Kommentar
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!