interpreter with backlash underscores

7 次查看(过去 30 天)
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

采纳的回答

Voss
Voss 2022-5-13
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')));

更多回答(1 个)

Adam Jurhs
Adam Jurhs 2022-5-13
gotcha, thanks!
  2 个评论
Adam Jurhs
Adam Jurhs 2022-5-13
wow! i didn't know i could run MATLAB code inside of this website. now i can post my question more specifically
Voss
Voss 2022-5-13
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by