-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplotlib_app.py
More file actions
60 lines (43 loc) · 934 Bytes
/
matplotlib_app.py
File metadata and controls
60 lines (43 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import matplotlib.pyplot as plt
import csv
# Plot show
x=[3,5,6,4,8]
y=[10,20,28,30]
plt.plot(x,y)
plt.title("simple line plot")
plt.xlabel("X-Axis")
plt.ylabel("Y-Axis")
plt.show()
# Bar Show
x=["Apple","Banana","Grapes"]
y=[10,15,45]
plt.bar(x,y, color="green")
plt.title("Fruit Count")
plt.ylabel("count")
plt.show()
# Scatter Show
x=[1,2,3,4,5]
y=[5,20,15,25,10]
plt.scatter(x,y, color="red")
plt.title("simple scatter plot")
plt.xlabel("x")
plt.ylabel("y")
plt.show()
# Reading csv files and show plot view
# Intialize empty lists
months=[]
sales=[]
# Read csv files
with open("data.csv","r") as file:
reader=csv.DictReader(file)
for row in reader:
months.append(row["months"])
sales.append(int(row["sales"]))
# Plot the data
plt.plot(months,sales,marker="0")
plt.title("Monthly sales report")
plt.xlabel("Months")
plt.ylabel("Sales")
plt.grid(True)
plt.tight_layout()
plt.show()