-
Notifications
You must be signed in to change notification settings - Fork 5
/
liveplot.py
54 lines (36 loc) · 976 Bytes
/
liveplot.py
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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 6 18:36:41 2017
@author: abhisheksingh
"""
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
import json
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)
def animate(i):
try:
with open('sample.txt','r') as outfile:
array = json.load(outfile)
except ValueError as err:
print err
else:
#print array
xar= [1, 2, 3, 4]
yar = []
xtitles = ['']
indexvalue = 0
for items in array:
#xar.append(int(x))
yar.append(array[items])
xtitles.append(items)
ax1.clear()
plt.bar(xar,yar, align='center')
plt.xticks(np.arange(5), xtitles)
def Main():
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
if __name__ == "__main__":
Main()