Disabling printing underscore as subscript in figures
1,240 ビュー (過去 30 日間)
古いコメントを表示
Underscores print as subscript in figures. Can I disable it because I want to print the underscores as well.
Thanks.
2 件のコメント
Michael Marcus
2019 年 4 月 11 日
編集済み: Stephen23
2019 年 4 月 11 日
Although this allows underscores to print, it does not allow special symbols such as \mum to work.. Does anyone know how to allow both.
Mike Marcus
Michael Marcus
2019 年 4 月 11 日
I did find out another way to keep the underscore. \_ does work ? I have answered my own question? Convert all underscores in the text to \_ instead of changing the interpreter to none.
採用された回答
Walter Roberson
2011 年 6 月 11 日
編集済み: Image Analyst
2018 年 1 月 17 日
Set the Interpreter property for that field to 'none'; the default for text() fields is LaTex.
title('This_title has an underline', 'Interpreter', 'none'); % Also works with xlabel() and ylabel()
12 件のコメント
Walter Roberson
2023 年 5 月 9 日
It appears that stackedplot treats titles differently. The great majority of plot types are within axes, and in those cases the axes has a Title property that is a text() object. But stackedplot() does not use axes: it is a direct parent of a figure, and the Title property for it is a character vector, with there being no Interpreter property.
It appears that you need to use the method suggested by @Jan in https://www.mathworks.com/matlabcentral/answers/9260-disabling-printing-underscore-as-subscript-in-figures#comment_20281 -- namely to replace the _ with \_
title(regexprep(filename, '_', '\\_'))
その他の回答 (1 件)
HE
2020 年 5 月 5 日
If you are using sprintf, \\_ should work for you.
Example from https://www.mathworks.com/matlabcentral/answers/94238-how-can-i-place-the-_-or-characters-in-a-text-command#comment_327816:
old_cells = sprintf('Old cells: Y = %3.3f (X) \\^ %1.3f',coefs_old);
young_cells = sprintf('Young cells: Y = %3.3f (X) \\^%1.3f',coefs_young);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!