File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
# -*- noplot -*-
3
3
import time
4
- from pylab import *
5
-
4
+ import matplotlib . pyplot as plt
5
+ import numpy as np
6
6
7
7
def get_memory ():
8
8
"Simulate a function that returns system memory"
9
- return 100 * (0.5 + 0.5 * sin (0.5 * pi * time .time ()))
10
-
9
+ return 100 * (0.5 + 0.5 * np .sin (0.5 * np .pi * time .time ()))
11
10
12
11
def get_cpu ():
13
12
"Simulate a function that returns cpu usage"
14
- return 100 * (0.5 + 0.5 * sin (0.2 * pi * (time .time () - 0.25 )))
15
-
13
+ return 100 * (0.5 + 0.5 * np .sin (0.2 * np .pi * (time .time () - 0.25 )))
16
14
17
15
def get_net ():
18
16
"Simulate a function that returns network bandwidth"
19
- return 100 * (0.5 + 0.5 * sin (0.7 * pi * (time .time () - 0.1 )))
20
-
17
+ return 100 * (0.5 + 0.5 * np .sin (0.7 * np .pi * (time .time () - 0.1 )))
21
18
22
19
def get_stats ():
23
20
return get_memory (), get_cpu (), get_net ()
24
21
25
22
# turn interactive mode on for dynamic updates. If you aren't in
26
23
# interactive mode, you'll need to use a GUI event handler/timer.
27
- ion ()
24
+ plt . ion ()
28
25
29
26
fig , ax = plt .subplots ()
30
- ind = arange (1 , 4 )
31
- pm , pc , pn = bar (ind , get_stats ())
27
+ ind = np . arange (1 , 4 )
28
+ pm , pc , pn = plt . bar (ind , get_stats ())
32
29
centers = ind + 0.5 * pm .get_width ()
33
30
pm .set_facecolor ('r' )
34
31
pc .set_facecolor ('g' )
@@ -48,4 +45,4 @@ def get_stats():
48
45
pn .set_height (n )
49
46
ax .set_ylim ([0 , 100 ])
50
47
51
- draw ()
48
+ plt . draw ()
You can’t perform that action at this time.
0 commit comments