Adding Title
The title() method in matplotlib module is used to specify the title of the visualization depicted and displays the title using various attributes.
Syntax:
matplotlib.pyplot.title(label, fontdict=None, loc=’center’, pad=None, **kwargs)
Example:
Python3
import matplotlib.pyplot as plt # initializing the data x = [ 10 , 20 , 30 , 40 ] y = [ 20 , 25 , 35 , 55 ] # plotting the data plt.plot(x, y) # Adding title to the plot plt.title( "Linear graph" ) plt.show() |
Output:
We can also change the appearance of the title by using the parameters of this function.
Example:
Python3
import matplotlib.pyplot as plt # initializing the data x = [ 10 , 20 , 30 , 40 ] y = [ 20 , 25 , 35 , 55 ] # plotting the data plt.plot(x, y) # Adding title to the plot plt.title( "Linear graph" , fontsize = 25 , color = "green" ) plt.show() |
Output:
Note: For more information about adding the title and its customization, refer Matplotlib.pyplot.title() in Python
Data Visualization using Matplotlib
Data Visualization is the process of presenting data in the form of graphs or charts. It helps to understand large and complex amounts of data very easily. It allows the decision-makers to make decisions very efficiently and also allows them in identifying new trends and patterns very easily. It is also used in high-level data analysis for Machine Learning and Exploratory Data Analysis (EDA). Data visualization can be done with various tools like Tableau, Power BI, Python.
In this article, we will discuss how to visualize data with the help of the Matplotlib library of Python.