-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadfile_matplotlib.py
More file actions
44 lines (41 loc) · 1.24 KB
/
loadfile_matplotlib.py
File metadata and controls
44 lines (41 loc) · 1.24 KB
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
import matplotlib.pyplot as plt
import csv
import numpy
from pyramid.response import Response
from pyramid.view import view_config
x = []
y = []
@view_config(route_name="load_file_matplotlib", request_method='POST')
def load_file_matplotlib(request):
data=request.json_body
file_name=data["file_name"]
attr1=data["X"]
attr2=data["Y"]
with open(file_name, 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
rownum=0
xnum=0
ynum=0
for row in plots:
if(rownum==0):
header = row
colnum=0
for col in row:
if col==attr1:
xnum=colnum
elif col==attr2:
ynum=colnum
colnum=colnum+1
rownum = rownum+1
if(rownum>1):
x.append(row[xnum])
y.append(row[ynum])
plt.scatter(x, y, label='Age-Salary', color='g', s=25, marker="*")
plt.xlabel(attr1)
plt.ylabel(attr2)
plt.xticks(numpy.arange(3))
plt.yticks(numpy.arange(3))
plt.title('Interesting Graph Check it out')
plt.legend()
plt.show()
return Response("Matplot lib loading file and visualizing it")