4 types of Data visualization using Matplotlib in Python

Kirti Pawar
4 min readMar 30, 2019

--

Data Visualization

Today, tones of data are generated, which has no structure. To handle this unstructured data, data visualization plays an important role. Visuals can easily help us understand complex data hence, data visualization is effective for handling huge clusters of data. In machine learning, data visualization is considered as an important part. This data visualization can be easily performed by using python libraries like Matplotlib

Matplotlib

there are many amazing libraries for data visualization in python like Pandas, Seaborn, Plotly and Cufflinks, etc. but the most popular among them is ‘Matplotlib’. It is known to be the foundation library for many other plotting libraries and also as a plotting support in many high-level libraries like Pandas. It is basically a Python 2D plotting library. It has the ability to play with many operating systems and graphics backend. Using matplotlib, we’ll study 4 easy data visualization types. They are listed below-

1. Line Plot

2. Histogram Plot

3. Bar Chart

4. Scatter Plot

Introduction to matplotlib

For downloading matplotlib library type the following command in your anaconda prompt

After installing the matplotlib library, open your jupyter notebook and start coding.

First, we will import the matplotlib library using the following command

To make charts and plots, the following function is made and called

And to view the charts and plots, the below command is used

Now let us see the four types of data visualization using matplotlib

1. Line Plot

Line plot is used for data that has regular intervals. It is also known as time series plot. It shows a trend over a period of time. The x-axis represents the regular time interval while y-axis represents the observations. It is created by calling plot() function. Example of line plot is given below

2. Histogram Plot

Histograms are used to display the distribution of data sample. The x-axis represents intervals for observations and y-axis represents the frequency of number of observations. They are basically density estimates. This plot can be created using hist() function. Example of histogram graph is given below

3. Bar Chart

This type of data visualization is basically used to represent relative quantities for multiple categories. X-axis represents intervals of categories while y-axis represents quantity of each category. It is created using the function bar(). Example of bar chart is given below

4. Scatter Plot

This type of visualization is used to represent relationship between two paired data samples. The x-axis represents observation values for first data sample while y-axis represents observation values for second data sample. It can be created using function scatter(). Example of scatter plot is given below

Conclusion

This article gives information about different data visualization types which are used to represent data for the convenience of the reader.

References:

https://machinelearningmastery.com/data-visualization-methods-in-python/

https://heartbeat.fritz.ai/introduction-to-matplotlib-data-visualization-in-python-d9143287ae39

--

--

Kirti Pawar

Computer Science Student | Python Enthusiast | Machine learning Enthusiast