matplotlib axes title code example

Example 1: set axis title matplotlib

fig.suptitle('test title', fontsize=20)
plt.xlabel('xlabel', fontsize=18)
plt.ylabel('ylabel', fontsize=16)

Example 2: matplotlib title inside plot

import matplotlib. pyplot as plt
A= [2,1,4,5]; B = [3,2,-2,1]
plt.scatter(A,B)
plt.title("title", x=0.9, y=0.9)
plt.xlabel("x-axis")
plt.ylabel("y-axis")
plt.show()

Example 3: set title matplotlib

import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 2)
axs[0].set_title('TITLE1')