Hat on letter on x/ylabel WITHOUT using LaTeX?
27 views (last 30 days)
Show older comments
Minas Emiris on 23 Apr 2020
Commented: Minas Emiris on 29 Apr 2020
I am wondering how I can add a 'hat' above a character on a plot without, however, changing the font to LaTeX, as I was my font style to remain default.
LaTeX is not the font, it's the text interpreter...sure probably know that, but just for clarification/precision of terminology.
Can't be done w/ TeX as an interpreted sequence; TeX only displays a character from the set in the table outlined in the documentation under the 'Interpreter' property at text function entry.
You can try to use text to write two characters
figure, plot(sort(rand(10,4))) % preliminaries...
hTxt=text(4,0.6,'x'); % location arbitrary for given data set
Not perfect bit fiddling w/ positioning, font size, etc., etc., may improve things a little. It looked less obtrusive and more aligned over the character on the figure itself than the saved one here for some reason.
More Answers (1)
Robert U on 23 Apr 2020
Hi Minas Emiris,
convert the circumflex from unicode to string via sprintf (see here, unicode table for combining characters found here) and use append to create the string for the labels (as shown here):
circumFlex = sprintf('\x0302')
fh = figure;
ah = axes(fh);
ah.XLabel.String = append('T',circumFlex);
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!