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()
xxxxxxxxxx
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()
xxxxxxxxxx
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 2)
axs[0].set_title('TITLE1')
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)