MATLAB Answers

How to avoid undercase in plot legend?

2 views (last 30 days)
Nik Rocky
Nik Rocky on 24 Jun 2020
Commented: Star Strider on 25 Jun 2020
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!

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 24 Jun 2020
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 Comments

Show 4 older comments
Star Strider
Star Strider on 24 Jun 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:
.
Nik Rocky
Nik Rocky on 25 Jun 2020
Perfekt, thank you! It works!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!