Plot multiple legend in a loop with variable
显示 更早的评论
Hello
In result folder are multiple subfolder with .mat-files (in this example 3)
I want load and print all .mat-files in one plot
Legend should show a .mat-filenames

I tried to make different dancing moves, but it still shows me just one (last filename) and data1 (that I want to remove)
Legends_results =
1×3 cell array
{'001_M1_0.5m_AKG_F1_MS1.mat'} {'002_M1_0.5m_AKG_F1_MS1.mat'} {'003_M1_0.5m_AKG_F1_MS1.mat'}
Help me please to:
- plot all names to legend
- remove/avoid plot "data1"
my code:
steps_SNR = 1; %%%change
addpath(genpath('/home/nikitajarocky/workspace/QT/Software_2.0_QT/IO/'));
i = dir('**/*.mat');
Legends_results = cell(1,length(i));
for p = 1:length(i)
roc_file_name = i(p).name;
load(roc_file_name)
disp(roc_file_name)
for a = 1:length(i)
Legends_results{a}=i(a).name;
f=@(m) repmat(c,1,nnz(Legends_results));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SNR_help = ((length(M)-1)/2)*steps_SNR;
SNR = -SNR_help:steps_SNR:SNR_help;
%figure('Name',' receiver operating characteristic','NumberTitle','on');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hold all
p1 = plot(M(:,2),M(:,1),'--o');
buffer = [.1 .3 .5];
buffer = repmat(buffer,1,ceil(numel(M(:,2))/numel(buffer)));
buffer(numel(M(:,2))+1:end) = [];
[~, ySortIdx] = sort(M(:,2));
buffer(ySortIdx) = buffer;
labelpoints(M(:,2),M(:,1), SNR, 'E', buffer)
%%%%%%%%%%%%%%%%%%%%%%%%%%%
hold all
lgd = legend([p1],Legends_results{p},'Interpreter','none','Location','Best');
title(lgd,'Compare AKG and Sony')
hold all
help_x = 0:0.1:1;
help_y = 0:0.1:1;
plot(help_x,help_y,'--','Color','g');
xlabel('False discovery rate')
ylabel('True positive rate')
xlim([0 1]);
ylim([0 1]);
set(get(get(gco,'Annotation'),'LegendInformation'),'IconDisplayStyle','off')
end
Thank you in advice!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


