Created
October 18, 2018 15:08
-
-
Save nikhilkumarsingh/142b29604acba61e8cb1b997bbb8dd3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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