Plot legend and axis label does not display
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Plot legend and axis label does not display, find codes below. Can anyone help?, Also, i would like to number each point PU(1, to 20) and SU(1 to 20) similar to the attached file.
%% Sample points considering a 10 × 10 area, consisting of 20 secondary usesrs (SUs) and 20 primary users (PUs)randomly distribute
SU = rand (20) * 10; % sample points
PU = rand (20) * 10; % sample points
%% figures
plot (SU (:, 1), SU (:, 2), '+ k' )
hold on
plot (PU (:, 1), PU (:, 2), '* k' )
hold off
text (SU (:, 1), SU (:, 2), compose ( '$ \\% d $' , 1: size (SU, 1)), 'Horiz' , 'left' , 'Vert' , ' middle ' , ' Interpreter ' , ' latex ' )
text (PU (:, 1), PU (:, 2), compose ( '$ \\% d $' , 1: size (PU, 1)), 'Horiz' , 'left' , 'Vert' , ' middle ' , ' Interpreter ' , ' latex ' )
legend('SU','PU')
0 Kommentare
Antworten (2)
Voss
am 19 Mär. 2022
Avoid putting extra spaces in character vectors, e.g., use:
'Vert' , 'middle' , 'Interpreter' , 'latex'
instead of:
'Vert' , ' middle ' , ' Interpreter ' , ' latex '
(MATLAB doesn't recognize ' Interpreter ' to be the same as 'Interpreter', for instance.)
%% Sample points considering a 10 × 10 area, consisting of 20 secondary usesrs (SUs) and 20 primary users (PUs)randomly distribute
SU = rand (20) * 10; % sample points
PU = rand (20) * 10; % sample points
%% figures
plot (SU (:, 1), SU (:, 2), '+ k' )
hold on
plot (PU (:, 1), PU (:, 2), '* k' )
hold off
text (SU (:, 1), SU (:, 2), compose ( '$ \\% d $' , 1: size (SU, 1)), 'Horiz' , 'left' , 'Vert' , 'middle' , 'Interpreter' , 'latex' )
text (PU (:, 1), PU (:, 2), compose ( '$ \\% d $' , 1: size (PU, 1)), 'Horiz' , 'left' , 'Vert' , 'middle' , 'Interpreter' , 'latex' )
legend('SU','PU')
Star Strider
am 19 Mär. 2022
Spaces are significant in name-value pair arguments, so ' Interperter ' will not be recognised.
%% Sample points considering a 10 × 10 area, consisting of 20 secondary usesrs (SUs) and 20 primary users (PUs)randomly distribute
SU = rand (20) * 10; % sample points
PU = rand (20) * 10; % sample points
%% figures
plot (SU (:, 1), SU (:, 2), '+ k' )
hold on
plot (PU (:, 1), PU (:, 2), '* k' )
hold off
text (SU (:, 1), SU (:, 2), compose ( '$ \\% d $' , 1: size (SU, 1)), 'Horiz' , 'left' , 'Vert' , 'middle' , 'Interpreter' , 'latex' )
text (PU (:, 1), PU (:, 2), compose ( '$ \\% d $' , 1: size (PU, 1)), 'Horiz' , 'left' , 'Vert' , ' middle ' , 'Interpreter' , 'latex' )
legend('SU','PU')
They display now!
.
Siehe auch
Kategorien
Mehr zu Annotations 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!