forked from MLSA-Mehran-UET/learn2code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRead_and_plot_CSV_Data.py
More file actions
19 lines (15 loc) · 955 Bytes
/
Copy pathRead_and_plot_CSV_Data.py
File metadata and controls
19 lines (15 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import matplotlib.pyplot as plt # here we are importing matplot library to plot data
import csv # here we imported CSV library to read CSV file
x = [] # here we declared an empty array variable
y = [] # here we declared an empty array variable
with open('Example.csv','r') as csvfile: # here we open CSV file
plots = csv.reader(csvfile, delimiter = ',') # ploting csv file data
for row in plots:
x.append(row[0]) # collecting data from rows and storing in array
y.append(int(row[2]))
plt.bar(x, y, color = 'g', width = 0.72, label = "Age") #ploting data with Labels
plt.xlabel('Names') # declaring Labels
plt.ylabel('Ages') # declaring Labels
plt.title('Ages of different persons') # declaring Title
plt.legend()
plt.show()