How can I create a multi-line title for my plot with different font properties for each line in MATLAB 7.6 (R2008a)?
8 views (last 30 days)
Show older comments
I create a plot with a multi-line title as follows,
plot(1:10);
title({'Performance','Memory'});
I would like to specify different font sizes for each line of the title.
Accepted Answer
MathWorks Support Team
on 12 Jan 2012
In MATLAB graphics, titles are merely single text objects associated with an axes object. Therefore, although a single text object may have multiple lines, an axes can only have a single text object representing its title. If you would like to create a multi-line title such that each line has its own font size (and other such properties) you will need to create separate text objects and place them appropriately in the figure.
The attached file is a sample function that will allow you to create such text objects at the top of an axes. The function makes an initial guess for the placement of the objects and expects the user to fine-tune the placement through plot tools or handle graphics. The function only allows the user to specify different font names and font sizes but the same approach can be generalized to allow the function to handle any number of different text object properties (such as font angle, color, etc). The function returns a vector of handles to each text object for further customization.
Copy the attached file to a directory on the MATLAB path and use the function as follows:
plot(1:10);
texthandles = multititle({'Performance','Memory'}, 'times new roman', [14 8]);
0 Comments
More Answers (0)
See Also
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!