xxxxxxxxxx
#adjust title position using 'loc' argument (left, center, right)
plt.title('My Title', loc='right')
#adjust title position using x and y coordinates
plt.title('My Title', x=0.5, y=1.1)
xxxxxxxxxx
import matplotlib.pyplot as plt
# Create a plot
plt.plot([1, 2, 3, 4, 5], [2, 4, 6, 8, 10])
# Add a title to the figure
plt.title("My Plot Title")
# Display the figure
plt.show()