W14-Lab A CBD

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

LAB MODULE

Coding & Big Data

Part 12

Pyplot with matplotlib


Outline Introduction
Try to Visualize
Use your Data
Tips n Trick
Practice
Submission
Introduction
What is Data Visualization library from
Python.
matplotlib? matplotlib is a comprehensive Python
library that is useful for creating static and
interactive data visualizations in 2D and 3D.
What inside
matplotlib?
You can try every function in matplotlib

Plt.Plot (): Produce plot graph

Plt.Bar (): Produce bar chart

Plt.Hist(): produce Histogram graph

Plt.Pie(): produce pie chart

Plt.Scatter(): produce scatter plot

Dropna(): remove missing value or zero value

For more reference about this click here


Note
From this module onwards, you can use Google Colaboratory service to do the practices. It is similar to
jupyter notebook, plus it is easy to set up. If you are not familiar with this service, please learn more about
the basics of using it so you don’t have problems following the module.
Chapter I:
Try to Visualize
Example
Code: Result:
How to resize the chart?

Resize Figure.
ADD This Code:
plt.figure(figsize=(W,H))
W = Width
H = Height

Example:
plt.figure(figsize=(16,10))
Chapter II:
Use your data for visualization
Import Your library and CSV dataset.
Information

Pay Attention with your columns name


when you declare It on your code.
(Sensitive Case)

Preview Your Data


This is the preview of the dataset opened using Excel
Example.
With Variable: Without Variable:
Result.
Bonus
Broken Barh.
Result.

For more reference for this Broken Barh Click Here or Here.
Stacked Bar Graph.
Result.

For more reference About this Stacked Bar Chart Click Here.
Tips n Trick (Additional)
Add label to your chart
Preview your data in excel
when you open the .csv file you can see that the data is not in table format.
Try this solution for solve your problem

Follow these steps:


• Follow these steps:
• Select whole Column A that contain with data
• On the data tab, click Text to columns
• Ensure Delimited is selected and click next
• Ensure comma is selected and click finish
Preview your data in excel
Practice
ODD Student ID
Use 10 last data from Dataset in Total cases of covid-19 and visualize the result for each country using
Bar Chart.

Even Student ID
Use 10 last data from Dataset in Total Recovered of covid-19 and visualize the result for each country
using Bar Chart.
Submission
Screenshot & Upload to eCampus
Screenshot your code and the output, then put them into a pdf file. After that upload them to eCampus.
Questions?
References
Covid-19 Cases Dataset from Kaggle

Ngodingdata.com

You might also like