How to write _ in a plot legend?

xxx = {'a_b'}
plot(1:5)
legend(xxx)
>> result is
i want to 'a_b' in legend .......
How to write ??

 Accepted Answer

Set the interpreter to 'none'
xxx = {'a_b'};
plot(1:5)
legend(xxx,'interpreter','none')

1 Comment

very very very very very very very very very Thank you !!!!
happy new year ~!~!

Sign in to comment.

More Answers (2)

  1. change the Interpreter like other answers
  2. Tex has its own escape for _ :
legend('a\_b');

Tags

Community Treasure Hunt

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

Start Hunting!