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