How to insert variable in multi-line, multi-font title?

5 views (last 30 days)
Hi,
I'm trying to insert a variable into a plot title, but the variable needs to have a different font and size to the rest of the text.
What I have now is
title({'\fontsize{14}AirfoilName';'\fontsize{10}\color{blue} ';...
'Coefficient of Lift';'vs Angle of Attack'},'fontweight','b');
This would work - except AirfoilName is a variable.
All I can find that may work are int2str(x), but this variable is already text.
My ultimate aim is a title on a figure which contains subplots. I can't get 'annotation('textbox'..)' or 'text' to work, so I gave up. I've also seen reference to something like 'suptit', but I've also seen reference to it being a dodgy file (or maybe it was just the one link?). I therefore gave up on that and was trying to do it in a subplot title instead.
Thanks,

Answers (1)

Walter Roberson
Walter Roberson on 8 Feb 2014
title({['\fontsize{14}', AirfoilName];'\fontsize{10}\color{blue} ';...
'Coefficient of Lift';'vs Angle of Attack'},'fontweight','b');
  2 Comments
Chase
Chase on 18 Mar 2015
How would you do the same, but while using:
'Interpreter','none'
?
Stephen23
Stephen23 on 18 Mar 2015
Edited: Stephen23 on 18 Mar 2015
@Chase: Markup is the name given to meta-information given in some text that controls how it will be displayed. When the text property Interpreter is set to none then there is no interpretation at all of these commands, so changes in color or font are not possible.
Walter Roberson's answer uses the default TeX syntax: any text that you can display as plain text can also be displayed using TeX, so there is no reason why you cannot use the method given by Walter Roberson.
Do you have some specific text that you wish to display? The properties documentation includes a list of TeX commands that you can use. Note that you can get an underscore character _ by entering \_, and a circumflex character ^ by entering \^.

Sign in to comment.

Categories

Find more on Labels and Annotations 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!