How do I place a title on top of a subplot, as a part of the figure, in MATLAB 7.4 (R2007a) ?
1 view (last 30 days)
Show older comments
I want to know how I can place a title string on top of a figure consisting of multiple subplots. The command TITLE only works for axes. So I can place a title for each of the subplots but not a 'super' title for the whole figure.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The ability to place a title string on top of a figure is not available in MATLAB.
To work around this issue, create a UICONTROL of the style 'text'. This will be a child of the figure and not of the axes. This way you can put the title anywhere on the figure. You can position the UIControl so that it acts like a title for the figure.
Following code will accomplish that:
h = figure;
uicontrol('Style', 'text', 'String', 'My Title', ...
'HorizontalAlignment', 'center', 'Units', 'normalized', ...
'Position', [0 .9 1 .05], 'BackgroundColor', [.8 .8 .8]);
h1 = subplot(3,1,1);
plot(1:10);
subplot(3,1,2);
plot(1:100);
subplot(3,1,3);
plot(1:100);
You may need to adjust the 'Position' or other properties of the UICONTROL to fine-tune the appearance for your application.
0 Comments
More Answers (0)
Categories
Find more on Subplots 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!