interpreter with backlash underscores

4 views (last 30 days)
Adam Jurhs
Adam Jurhs on 13 May 2022
Commented: Voss on 13 May 2022
hi guys,
i have a csv file that has some underscores in the strings that i use as xticklabels. i understand the the interpreter will interpret underscores to be use the following text as subscript unless you put a backslash in front of the underscore. sometimes this works perfectly other times it doesn't, see example:
abc\_def -> abc_def as it's supposed to other times it gives me abc\_def -> abc\_def keeping the backslash as part of the string
any ideas

Accepted Answer

Voss
Voss on 13 May 2022
The easiest way to fix this might be not to use an interpreter:
subplot(2,1,1)
xlim([-1 1])
set(gca(),'XTick',0,'XTickLabels','abc_def')
xax = get(gca(),'XAxis');
title(sprintf('Interpreter: %s',get(xax,'TickLabelInterpreter')));
subplot(2,1,2)
xlim([-1 1])
set(gca(),'XTick',0,'XTickLabels','abc_def')
xax = get(gca(),'XAxis');
set(xax,'TickLabelInterpreter','none')
title(sprintf('Interpreter: %s',get(xax,'TickLabelInterpreter')));

More Answers (1)

Adam Jurhs
Adam Jurhs on 13 May 2022
gotcha, thanks!
  2 Comments
Voss
Voss on 13 May 2022
Yeah, it's pretty cool what MathWorks has put together for us here.
Modify your question as necessary, to demonstrate the problem, and I'll modify my answer to address it if I can.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!