Python | Title Rotation in Matplotlib

Here, we are going to learn about the title rotation in matplotlib and its Python implementation.
Submitted by Anuj Singh, on August 03, 2020

In this tutorial, we are going to rotate the title of a figure using matplotlib inbuilt command rotation=angle.

Examples:

Python | Title Rotation in Matplotlib (1)

Python | Title Rotation in Matplotlib (2)

Python | Title Rotation in Matplotlib (3)

Python code for title rotation in matplotlib

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(100)
y = np.random.randint(45,86,100)

plt.figure()
plt.plot(x,y, 'o')
plt.title('Title : ABC', loc='left', rotation=30)
plt.grid()
plt.show()

plt.figure()
plt.plot(x,y, 'o')
plt.title('Title : ABC', loc='Right', rotation=-45)
plt.grid()
plt.show()

plt.figure()
plt.plot(x,y, 'o')
plt.title('Title : ABC', loc='Center', rotation=90)
plt.grid()
plt.show()

Output:

Output is as figure



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.