How to write _ in a plot legend?

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

Accepted Answer

Cris LaPierre
Cris LaPierre on 4 Feb 2021
Set the interpreter to 'none'
xxx = {'a_b'};
plot(1:5)
legend(xxx,'interpreter','none')
  1 Comment
도현 김
도현 김 on 4 Feb 2021
very very very very very very very very very Thank you !!!!
happy new year ~!~!

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 4 Feb 2021
legend(xxx, 'interpreter', 'none')

weikang zhao
weikang zhao on 4 Feb 2021
  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!