Disabling printing underscore as subscript in figures

1.225 Ansichten (letzte 30 Tage)
AP
AP am 11 Jun. 2011
Kommentiert: Yulong Li am 9 Mai 2023
Underscores print as subscript in figures. Can I disable it because I want to print the underscores as well.
Thanks.
  2 Kommentare
Michael Marcus
Michael Marcus am 11 Apr. 2019
Bearbeitet: Stephen23 am 11 Apr. 2019
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
Michael Marcus am 11 Apr. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Jun. 2011
Bearbeitet: Image Analyst am 17 Jan. 2018
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 Kommentare
Walter Roberson
Walter Roberson am 9 Mai 2023
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, '_', '\\_'))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

HE
HE am 5 Mai 2020
If you are using sprintf, \\_ should work for you.
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);

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by