VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-set-a-single-main-title-for-all-the-subplots-in-matplotlib/

⇱ How to Set a Single Main Title for All the Subplots in Matplotlib? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Set a Single Main Title for All the Subplots in Matplotlib?

Last Updated : 23 Jul, 2025

A title in Matplotlib library describes the main subject of plotting the graphs. Setting a title for just one plot is easy using the title() method. By using this function only the individual title plots can be set but not a single title for all subplots. Hence, to set a single main title for all subplots, suptitle() method is used.

Syntax: suptitle(self, t, **kwargs)

Parameters: This method accept the following parameters that are discussed below:

  • t : This parameter is the title text.
  • x: This parameter is the x location of the text in figure coordinates.
  • y: This parameter is the y location of the text in figure coordinates.
  • horizontalalignment, ha : This parameter is the horizontal alignment of the text relative to (x, y).
  • verticalalignment, va : This parameter is the vertical alignment of the text relative to (x, y).
  • fontsize, size : This parameter is the font size of the text.
  • fontweight, weight : This parameter is the font weight of the text.

Returns: This method returns the Text instance of the title.

Setting a Single Title for All the Subplots

Example 1:

In this example, we will import the required library and create a 2*2 plot. We are creating random data by using random.randint to plot our graph and then setting a single title for all the subplots.

Output:

👁 et a Single Title for All the Subplots
 

Example 2:

Here, we are creating data to plot our graph and using a marker.

Comment