File Exchange

image thumbnail

A single title on top of a subplot

version 1.1.0.0 (1006 Bytes) by Shoaibur Rahman
Use this function to print a title on the top of a group of subplots

23 Downloads

Updated 28 Jan 2016

View License

When using subtitle('MY TITLE','PorpertyName','PropertyValue'...), or subtitle('MY TITLE') after a group of subplots, then it provides a title MY TITLE with any property used that is defined in the original title function in Matlab, but without affecting the titles, xlables and ylabels of any of the subplots.
Make sure to use the function after the group of subplots.
Example
x = 0:0.01:6;
subplot(221), plot(x,sin(x)), xlabel('x'), ylabel('sin(x)'), title('sin(x)')
subplot(222), plot(x,cos(x)), xlabel('x'), ylabel('cos(x)'), title('cos(x)')
subplot(223), plot(x,sin(2*x)), xlabel('x'), ylabel('sin(2x)'), title('sin(2x)')
subplot(224), plot(x,cos(2*x)), xlabel('x'), ylabel('cos(2x)'), title('cos(2x)')
subtitle('Single title on top','FontSize',12,'Color','r')
See also:
title, suplabel, subplot

Cite As

Shoaibur Rahman (2019). A single title on top of a subplot (https://www.mathworks.com/matlabcentral/fileexchange/48742-a-single-title-on-top-of-a-subplot), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

It works very well. But when I try to put in my title something like "_Title", the "T" goes in subscript. How can I fix it?

you can put a vertical offset to the supertitle with supertitle('your title \newline ') so the supertitle wont overlap with any of the subplots title. Dont forget the space between \newline and Apostrophe.

sampath S

how to insert this new file

Raazu

Superb. It is working fine.

Kia Miller

MHRosenberg

I agree with Matt's issue with the vertical position. Without handling the offset, this function does not help me in the slightest.

Raghavi B

There was an error in line 6 in the example given. Replace the 'subtitle' command as 'supertitle'.
It works great. Thanks.

Matt

The function does not address the vertical position of the "supertitle," which causes interferences with normal titles in some configurations. To use the example in the file description (2x2), the "supertitle" is placed at the same vertical position as the titles of the plots in the top row. If the "supertitle" is longer than the space between the two normal titles, they will overlap.

Backer

Problem solved. Thanks!

Anvya

Works good with subplots. But if I use this function, I cannot use the linkaxes functionality as the axes is set to 'off'. Any workarounds?

John

Simple and easy to use, but works like a magic what exactly I wanted!

Adam Danz

Similar to "suptitle" in the bioinfo toolbox except does not re-adjust subtitle axes.

Updates

1.1.0.0

Change title

1.1.0.0

Name changes to supertitle

1.1.0.0

Description

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux