Professional Documents
Culture Documents
AP19110010030 Assiggnmnet-3
AP19110010030 Assiggnmnet-3
Kilaru Sravan
AP19110010030
CSE-A
Matplot Library
Matplotlib is an amazing visualization library in Python for 2D plots of arrays.
Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the
broader SciPy stack. It was introduced by John Hunter in the year 2002.
One of the greatest benefits of visualization is that it allows us visual access to huge amounts of data in
easily digestible visuals.
Matplotlib consists of several plots like line, bar, scatter, histogram etc
In [2]:
import pandas as pd
In [3]:
localhost:8888/notebooks/AP19110010030_Assiggnmnet-3.ipynb 1/5
28/08/2021 AP19110010030_Assiggnmnet-3 - Jupyter Notebook
In [5]:
Histogram
A histogram is used to display the distribution of information or data over a continuous time period.
Histograms may have a similar appearance to bar charts but unlike them, are used to plot the frequency of
variable occurrences in continuous data and this continuous data is divided into classes called bins.
A histogram is used to display continuous data in a categorical form.
In a histogram, there are no gaps between the bars, unlike a bar graph.
In [8]:
plt.hist(df["out"])
plt.xlabel("No.of outs")
plt.ylabel("No.of players")
plt.show()
Pie chart
Pie Charts help show proportions and percentages between categories, by dividing a circle into
proportional segments.
Each arc length represents a proportion of each category, while the full circle represents the total sum of all
the data, equal to 100%.
A Pie Chart can only display one series of data. Pie charts show the size of items (called wedge) in one
data series,proportional to the sum of the items.
Matplotlib API has a pie() function that generates a pie diagram representing data in an array. The
fractional area of each wedge is given by x/sum(x).
localhost:8888/notebooks/AP19110010030_Assiggnmnet-3.ipynb 2/5
28/08/2021 AP19110010030_Assiggnmnet-3 - Jupyter Notebook
In [11]:
Box plot
A box plot visualization allows you to examine the distribution of data.
Each box plot displays the minimum, first quartile, median, third quartile, and maximum values.
In addition, you can choose to display the mean and standard deviation as dashed lines and outliers
appear as points in the visualization.
In [12]:
plt.boxplot(df["total_runs"])
plt.show()
Scatter plot
localhost:8888/notebooks/AP19110010030_Assiggnmnet-3.ipynb 3/5
28/08/2021 AP19110010030_Assiggnmnet-3 - Jupyter Notebook
A scatter plot is a type of data visualization that shows the relationship between different variables.
Scatter plots can also be known as scatter diagrams or x-y graphs, and the point of using one of these is to
determine if there are patterns or correlations between two variables.
The dots in a scatter plot not only report the values of individual data points, but also patterns when the
data are taken as a whole
Identification of correlational relationships are common with scatter plots.
In [14]:
plt.scatter(df["out"][:10],df["batsman"][:10])
plt.xlabel("no.of out")
plt.ylabel("Player name")
plt.show()
Column chart
Column Charts are used for showing data changes over a period of time or for illustrating comparison
among items.
In Column Charts, categories are along the horizontal axis and values along the vertical axis.
Column charts are typically used to compare several items in a specific range of values.
Column charts are ideal if you need to compare a single category of data between individual sub-items
Column charts work well in showing data changes over a period of time by displaying the comparisons
among subjects on an overall chart.
localhost:8888/notebooks/AP19110010030_Assiggnmnet-3.ipynb 4/5
28/08/2021 AP19110010030_Assiggnmnet-3 - Jupyter Notebook
In [19]:
localhost:8888/notebooks/AP19110010030_Assiggnmnet-3.ipynb 5/5