How do I control the text format of titles and labels on my graphs?

1 view (last 30 days)
I want to have more control over the titles in graphs produced using PLOT. I would like to have multiple line titles, in multiple fonts and colors.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Feb 2023
Edited: MathWorks Support Team on 16 Apr 2023
This enhancement has been incorporated in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
One way to create multiple line titles is to create a cell array as described at the following URL:
You can also use STRVCAT. For example,
str1='Hello';
str2='There';
str_title=strvcat(str1,str2);
plot(1:10)
h2=title(str_title);
In addition, you can change some aspects (fontsize, font, etc.) using various TeX symbols. There is an example of this in the MATLAB documentation, which may be obtained by typing the following command in the MATLAB Command Window:
web([docroot '/techdoc/creating_plots/annota20.html#28390'])
Following command may be used to view a list of the different TeX characters available in MATLAB:
web([docroot '/techdoc/ref/text_props.html#String'])
Lastly, an enhancement request has been forwarded to our development staff so that improvements to multiple lined titles and labels, such as multiple font colors, may be considered in a future release of MATLAB. There is no time frame for if or when this will be implemented.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!