How to avoid undercase in plot legend?

Hello,
i have names like:
roc_file_name =
'003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat'
  1. how can i avoid the lower case in legend?
  2. How can i open new legends "on the fly" (somethink like hold on for plots)
And another question, by the way -
if I have a full path:
fullfile(FilePath,roc_file_name)
ans = '/home/user/workspace/QT/Software_2.0_QT/IO/Motor_Set_1/AKG_C1000S/Distance_0.5m/Scenario_M1/003_m1_30_90_ramp_20200611_200632/003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat'
can I easy convert to
short_name = 'MS1/AKG/0.5m/M1/003' or short_name = 'MS1_AKG_0.5m_M1_003' or simmilar?
Thank you!

 Risposta accettata

Try this:
legend('003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat', 'Interpreter','none')
It ‘turns off’ the existing interpreter for that legend object only. (This also works for other text objects.)
.

7 Commenti

Thank you for answer, but its not working! Absolutley no effect!
your example looks so
It worked correctly when I tested it (in R2020a), or I would not have posted it.
My test code:
x = 1:20;
y = rand(size(x));
figure
plot(x, y)
legend('003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat', 'Interpreter','none')
My result:
It obviously worked correctly for me.
.
It seams to be a version Problem:
Do you know maybe how to put multiple Legend for anknown amount of Measures? (in foor loop)
I print allready al 3 files in directory, but still one (last) name
Code:
steps_SNR = 1; %%%input
i = dir('**/*.mat');
for p = 1:length(i)
roc_file_name = i(p).name;
load(roc_file_name)
disp(roc_file_name)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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],roc_file_name,'Interpreter','none','Location','Best');
title(lgd,'Compare AKG and Sony')
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]);
end
Star Strider
Star Strider il 24 Giu 2020
Modificato: Star Strider il 24 Giu 2020
That may be.
The only work-around I am aware of is to replace the underscores (_) with backslant-underscores (\_).
Try this:
legend(strrep('003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat','_','\_'))
You can do it manually if you like. I use strrep here.
EDIT — (24 Jun 2020 at 21:48)
Another option:
hl = legend('003_m1_30_90_ramp_20200611_200632_SNR_F1_PLL.mat');
set(hl, 'Interpreter','none')
I have not needed to do this in years, so I just now remembered it:
.
Perfekt, thank you! It works!
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by