Python | Sup-Title in Figure using Matplotlib

In this tutorial, we are going to learn how to add sup-title to a figure using matplotlib?
Submitted by Anuj Singh, on August 03, 2020

There is a function defined for our desired operation matplotlib.pyplot.suptitle().

Illustration:

Python sup-title 1

Python sup-title 2

Python code for sup-title in figure using matplotlib

import matplotlib.pyplot as plt
import numpy as np

#random data generation
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(100)

mu_w = 200
sigma_w = 10
w = np.random.normal(mu_w, sigma_w, size=100)

#Illustration 1
plt.plot(x,w, 'o', color='purple')
plt.suptitle('ABCD : This is SupTitle')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.title('This is Tittle')
plt.show()

#Illustration 2
plt.figure(figsize=(10,7))
plt.suptitle('ABCD : This is SupTitle')
plt.subplot(221)
plt.plot(x,w, 'r--')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.title('          A')

plt.subplot(222)
plt.plot(x,w, '--', color='purple')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.title('          B')

plt.subplot(223)
plt.plot(x,w, '1', color='purple')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')

plt.subplot(224)
plt.plot(x,w, '-', color='purple')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.show()

Output:

Output is as figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.