MATLAB: Varying Font Size Within individual words

font sizeMATLAB

I need to produce the symbol "FA/FI" on the y-axis label with the "A" and the "I" in a font 3 sizes smaller than each "F". I do not want to use subscripts. In Microsoft Word, one achieves this by clicking on an icon on the toolbox. How does one do it in Matlab?

Best Answer

Amazing how the same or similar queries seem to come in bunches...
hAx=gca;
hAx.XTickLabel(3)={'\color{red}\fontsize{8}\bf 3'};
did one tick value for the OP there. Just string together the two pieces you need. Write a simple function to produce the desired string passed the text and sizes if doing it for more than just one or two specific cases.
fmt='\\fontsize{%d} %s'; % format string for piece
>> [sprintf(fmt,8,'F',5,'A') '/' sprintf(fmt,8,'F',5,'I')]
ans =
'\fontsize{8} F\fontsize{5} A/\fontsize{8} F\fontsize{5} I'
>>
or, more directly to use passed string, size--
fnLbl=@(FS,S) {[sprintf(fmt,FS,S(1)) sprintf(fmt,FS-3,S(2)) sprintf(fmt,FS,'/') sprintf(fmt,FS,S(3)) sprintf(fmt,FS-3,S(4))]};
>> lbl=fnLbl(8,'FAFI')
lbl =
1×1 cell array
{'\fontsize{8} F\fontsize{5} A\fontsize{8} /\fontsize{8} F\fontsize{5} I'}
>> hAx.XTickLabel(4)=lbl;
produced the desired string. More logic in a function could make it somewhat simpler.
But, MATLAB handle graphics aren't a word processor and there's no fancy GUI to mung on stuff inside the tick labels array. Guess one could write one.
NB: Above w/ default 'TeX' interpreter as per the link...