Changing the location of title with x and y coordinates

In this method, we will place title inside the plot. Instead of giving the location in the “loc” parameter, we will give the exact location where it should be placed by using X and Y coordinates. 

Syntax:

 matplotlib.pyplot.title('Title', x=value, y=value)

Example:

In this example, we will be assigning the value of the x and y at the position where the title is to be placed in the python programming language.

Python3




#import matplotlib
import matplotlib.pyplot as plt
  
# Points to mark
plt.plot([1, 2, 3, 4, 5], [1, 4, 6, 14, 25])
  
# X label
plt.xlabel('X-axis')
  
# Y label
plt.ylabel('Y-axis')
  
# Title
plt.title('Title', x=0.4, y=0.8)


Output:

How to Adjust Title Position in Matplotlib?

In this article, you learn how to modify the Title position in matplotlib in Python.

Similar Reads

Method 1: Using matplotlib.pyplot.title() function

The title() method in matplotlib module is used to specify title of the visualization depicted and displays the title using various attributes....

Method 2: Changing the location of title with x and y coordinates

...

Method 3: Changing the location of title with pad parameter

...