0% found this document useful (0 votes)
9 views

5.3 Matplotlib

Uploaded by

abhinay.p
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

5.3 Matplotlib

Uploaded by

abhinay.p
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

PP_Module 5.

3
Data description
• The numerical findings of a study should be presented clearly, concisely, and in such a manner
that an observer can quickly obtain a feel for the essential characteristics of the data.

• Over the years it has been found that tables and graphs are particularly useful ways of
presenting data, often revealing important features such as the range, the degree of
concentration, and the symmetry of the data.

• Now we will discuss some common graphical and tabular ways for presenting data.

10/27/202
Python programming
3
DESCRIBING DATA SETS
• Frequency Tables and Graphs_Line,Bar,Pie
• Grouped Data_Scatter Plots
• Histograms

10/27/2023 Python programming


Frequency Tables and Graphs
• Frequency table for a data set consisting of the starting yearly salaries
(to the nearest thousand dollars) of 42 recently graduated students

10/27/2023 Python programming


Line graph

10/27/2023 Python programming


Bar graph

10/27/2023 Python programming


Relative Frequency Tables and Graphs
• Consider a data set consisting of n values. If f is the frequency of a particular
value, then the ratio f /n is called its relative frequency

10/27/2023 Python programming


Pie Chart

10/27/2023 Python programming


Grouped Data, Histograms

• Divide the values into groupings, or class intervals, and then plot the
number of data values falling in each class interval
• The endpoints of a class interval are called the class boundaries
• We will adopt the leftend inclusion convention

10/27/2023 Python programming


10/27/2023 Python programming
Histogram

Frequency histogram

10/27/2023 Python programming


PAIRED DATA SETS
• Sets that consist of pairs of values that have some relationship to each
other
• Data set of paired values is to plot the data on a two dimensional
graph,
• The x-axis representing the x value of the data
• The y-axis representing the y value. Such a plot is called a scatter
diagram

10/27/2023 Python programming


10/27/2023 Python programming
Scatter Diagram

10/27/2023 Python programming


Matplot library
• Matplotlib is a plotting library for the Python programming language
and its numerical mathematics extension NumPy.
• It provides an object-oriented API for embedding plots into
applications

10/27/2023 Python programming


Python Matplotlib

• Markers
• line
• labels
• grid
• subplot
• scatterplot
• histogram
• bar chart
• pie charts
10/27/2023 Python programming
Python Matplotlib

• Matplotlib is a comprehensive library for creating static, animated,


and interactive visualizations in Python. Matplotlib makes easy things
easy and hard things possible.
• Important Types of Plots
• Line chart
• Bar graphs
• Histograms
• Scatter plots

10/27/2023 Python programming


Line graph

10/27/2023 Python programming


Examples:
• Draw two points in the diagram, one at position (1,
3) and one in position (8, 10):

• The plot() function


is used to draw
points (markers) in
a diagram.
• By default,
the plot() function
draws a line from
point to point.
• Parameter 1 is an
array containing the
points on the x-axis.
• Parameter 2 is an
array containing the
points on the y-axis.

10/27/2023 Python programming


Markers and grids
• Marker list
o Circle

* Star

. Point

p Pixel

x/X X

+/p Plus

s Square

d/D Diamond

p Pentagon

H/h Hexagon

v/^ Triangle down/up

</> Triangle Left/right

1/2 / Tri up/down/left/right


3/4
| Vline

_ Hline
10/27/2023 Python programming
Marker formatting: colour, line style, marker size(use ms)

• Line options(line style is written • Colour options


as ls)
r Red
'-.' Dashed/dotted
line g Green
'--' Dashed line B Blue
':' Dotted line C Cyan
'-' Solid line m Magneta
y Yellow
plt.plot(ypoints, linewidth = '20.5')
plt.show() K Black
w White

10/27/2023 Python programming


Examples:

10/27/2023 Python programming


Multiple lines (use plt.plot())

10/27/2023 Python programming


Formatting of titles and labels

10/27/2023 Python programming


Grid lines (use plt.grid)

10/27/2023 Python programming


Create multiple plots using subplot

10/27/2023 Python programming


Create scatter plot(use the scatter() function)

10/27/2023 Python programming


Change the size of scatterplot

10/27/2023 Python programming


Creating Bars

Change colour using color example-plt.bar(x, y, color = "red") change widh example: plt.bar(x, y, width = 0.1)
10/27/2023 Python programming
Histogram : to show frequency distributions

10/27/2023 Python programming


Pie Charts (use the pie() function to draw pie charts)

10/27/2023 Python programming


Settings: Colour, legend

10/27/2023 Python programming


References
• https://www.w3schools.com/python/matplotlib_pyplot.asp
• https://www.simplilearn.com/tutorials/python-tutorial/matplotlib

10/27/2023 Python programming

You might also like