Update title and labels of the plot - Python Mathplotlib Module

Author: Al-mamun Sarkar Date: 2020-04-02 07:07:38

Update title and labels of plot - Python Mathplotlib Module. The following code shows how to update title and labels of line chart using pyplot of matplotlib module.

Import module:

import matplotlib.pyplot as plt

Create Data:

x = [10, 25, 30]
y = [30, 60, 40]

 

Update title and Lables:

plt.plot(x, y)
plt.title("This is Plot Title")
plt.xlabel('Label for X-Axis')
plt.ylabel('Label of Y-Axis')
plt.show()

 

Adding line break on title:

plt.plot(x, y)
plt.title("Welcome to the Ploting \n This is Another line")
plt.xlabel('Plot Number')
plt.ylabel('Important Var')
plt.show()