Data Visualization using Matplotlib


Data Visualization

Home matplotlib Data Visualization using Matplotlib

Data visualization allows us to quickly interpret the data and adjust different variables to see their effec

Why data visualization is needed?

  • Ovserve the pattern
  • Identify extream values that could be anomalies
  • Easy interpretation


  • Matplotlib is a 2d plotting library which produces good quality figures
  • Althought it has its orgins in emulating the matlab graphics commands it is independent of matlab
  • It makes heavy use of numpy and other extension code to provide good performance even for large arrays

lets now read the dataframe using pandas,

You can download the data frame below

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

Scatter plot

A scatter plot is a set of points that represents the values obtaied for two different variables plotted on a horizontal and vertical axes

Uses of scatter plot

  • Scatter plots are used to convey the relationship between two numerical variables
  • Scatter plots are sometimes called correlation plots vecause they show how two variavles are correlated
plt.title("scatter plot of price vs age of the cars")

using scatter function you can give x-axis,y-axis,color Syntax : plt.scatter(x-axis,y-axis,c=”color”)

title is used to give title for the plot and xlabel,ylabel are used to give title for x and y axis


  • It is a graphical representation of data using bars of diffrent heights
  • Histogram groups numbers into ranges and the height of each bar depicts the frequency of each range or bin

Uses of histogram

To represent the frequency distribution of numerical variables

plt.hist(data['KM'] , color='green' , edgecolor='white' , bins=5)
plt.title('histogram of kilometer')

Bar plot

A bar plot is a plot that presents categorical data with rectagular bars with lengths proportional to the counts that they represent

Uses of bar plot

To represent the frequency distribution of categorical variables

A bar diagram makes it easy to comapre sets of data between different groups

plt.title("bar plot for fuel types")
plt.xlabel("fuel types")


Hephzibai is a driven third-year student at St. Joseph's Institute of Technology, specializing in Computer Science and Engineering. With a keen interest in data science and also in fullstack.
One of my greatest strengths lies in my programming skills, which I've honed through countless hours of practice and participation in coding challenges. Platforms like Skillrack, HackerRank, and others have been my playgrounds, where I've tackled a wide range of problems with creativity and determination.

Leave a Reply

Your email address will not be published. Required fields are marked *