Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Created October 18, 2018 15:08
Show Gist options
  • Save nikhilkumarsingh/142b29604acba61e8cb1b997bbb8dd3c to your computer and use it in GitHub Desktop.
Save nikhilkumarsingh/142b29604acba61e8cb1b997bbb8dd3c to your computer and use it in GitHub Desktop.
import time
import psutil
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
fig.show()
i = 0
x, y = [], []
while True:
x.append(i)
y.append(psutil.cpu_percent())
ax.plot(x, y, color='b')
fig.canvas.draw()
ax.set_xlim(left=max(0, i-50), right=i+50)
time.sleep(0.1)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment