Problem in specifying legend in multiple lines and symbols plot
I’ve created a MATLAB script to generate a plot with four lines of different colors and three symbols. Now, I need to add specific legends: the four color lines (green, blue, black, red) should represent the variables stored in `D_cond` as {‘Mno’,’Mot’,’Mor’,’Cse’}, and below that the three symbols of black color (pentagon, square, circle) should represent those stored in `C_con` as {‘Pr’,’7 s’,’10 s’}. Can anyone please help me to get this legends?
data = xlsread("me.xlsx", "Sheet1",’A:D’)
k = figure;
for loop2 = 1:4
values = data(:,loop2);% 5.9413
me = values’
vel_end = 4;
ve1 = 0:vel_end/40:vel_end
xaxis = sort(ve1′);
SD = [0.1 0.1 0.1];%[0.0568 0.0719 0.1002];% 0.109];
marker_symbols = {‘o’, ‘s’, ‘p’}; % Add more marker symbols if needed
colors = {[0 0.5 0], [0 0 1], [0 0 0], [1 0 0]}; % Specify colors for each loop iteration
for loop1 = 1:3
for loop = 1:length(ve1) % Change the increment to 20
sink(loop, 1) = (log(xaxis(loop, 1) / me(1, loop1))) / SD(1, loop1);
yaxis1(loop, 1) = normcdf(sink(loop, 1));
end
hold on;
plot(ve1, yaxis1, ‘Color’,[colors{loop2}], ‘Marker’, marker_symbols{loop1}, ‘MarkerFaceColor’, [1 1 1], ‘MarkerSize’, 6, ‘LineWidth’, 1.2);
hold on
D_cond = {‘Mno’,’Mot’,’Mor’,’Cse’}
C_cond = {‘Pr’,’7 s’,’10 s’}
hold off
end
endI’ve created a MATLAB script to generate a plot with four lines of different colors and three symbols. Now, I need to add specific legends: the four color lines (green, blue, black, red) should represent the variables stored in `D_cond` as {‘Mno’,’Mot’,’Mor’,’Cse’}, and below that the three symbols of black color (pentagon, square, circle) should represent those stored in `C_con` as {‘Pr’,’7 s’,’10 s’}. Can anyone please help me to get this legends?
data = xlsread("me.xlsx", "Sheet1",’A:D’)
k = figure;
for loop2 = 1:4
values = data(:,loop2);% 5.9413
me = values’
vel_end = 4;
ve1 = 0:vel_end/40:vel_end
xaxis = sort(ve1′);
SD = [0.1 0.1 0.1];%[0.0568 0.0719 0.1002];% 0.109];
marker_symbols = {‘o’, ‘s’, ‘p’}; % Add more marker symbols if needed
colors = {[0 0.5 0], [0 0 1], [0 0 0], [1 0 0]}; % Specify colors for each loop iteration
for loop1 = 1:3
for loop = 1:length(ve1) % Change the increment to 20
sink(loop, 1) = (log(xaxis(loop, 1) / me(1, loop1))) / SD(1, loop1);
yaxis1(loop, 1) = normcdf(sink(loop, 1));
end
hold on;
plot(ve1, yaxis1, ‘Color’,[colors{loop2}], ‘Marker’, marker_symbols{loop1}, ‘MarkerFaceColor’, [1 1 1], ‘MarkerSize’, 6, ‘LineWidth’, 1.2);
hold on
D_cond = {‘Mno’,’Mot’,’Mor’,’Cse’}
C_cond = {‘Pr’,’7 s’,’10 s’}
hold off
end
end I’ve created a MATLAB script to generate a plot with four lines of different colors and three symbols. Now, I need to add specific legends: the four color lines (green, blue, black, red) should represent the variables stored in `D_cond` as {‘Mno’,’Mot’,’Mor’,’Cse’}, and below that the three symbols of black color (pentagon, square, circle) should represent those stored in `C_con` as {‘Pr’,’7 s’,’10 s’}. Can anyone please help me to get this legends?
data = xlsread("me.xlsx", "Sheet1",’A:D’)
k = figure;
for loop2 = 1:4
values = data(:,loop2);% 5.9413
me = values’
vel_end = 4;
ve1 = 0:vel_end/40:vel_end
xaxis = sort(ve1′);
SD = [0.1 0.1 0.1];%[0.0568 0.0719 0.1002];% 0.109];
marker_symbols = {‘o’, ‘s’, ‘p’}; % Add more marker symbols if needed
colors = {[0 0.5 0], [0 0 1], [0 0 0], [1 0 0]}; % Specify colors for each loop iteration
for loop1 = 1:3
for loop = 1:length(ve1) % Change the increment to 20
sink(loop, 1) = (log(xaxis(loop, 1) / me(1, loop1))) / SD(1, loop1);
yaxis1(loop, 1) = normcdf(sink(loop, 1));
end
hold on;
plot(ve1, yaxis1, ‘Color’,[colors{loop2}], ‘Marker’, marker_symbols{loop1}, ‘MarkerFaceColor’, [1 1 1], ‘MarkerSize’, 6, ‘LineWidth’, 1.2);
hold on
D_cond = {‘Mno’,’Mot’,’Mor’,’Cse’}
C_cond = {‘Pr’,’7 s’,’10 s’}
hold off
end
end legends MATLAB Answers — New Questions